Weird issue with org-roam-capture-template and prompt expansion

Hi!
I’m trying to use this template with org-roam-capture-template.

My idea is anytime I create a note, the template ask me for the ID.

(setq org-roam-capture-templates
      '(("n" "note" plain "%?"
         :target (file+head "%^{id}-${slug}.org"
":PROPERTIES:
:ID: %\\1
:Time-stamp: <>
:END:
#+TITLE: %\\1 ${title}
#+DATE: %U")))

However, I am getting this error when it tries to expand the %\\1 and halts the capture process.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  replace-match(nil nil t)
  org-capture-fill-template("\n:PROPERTIES:\n:ID: %\\1\n:Time-stamp: <>\n:END:\n#+TITLE: %\\1 YY\n#+DATE: %U")
  org-roam-capture--fill-template("\n:PROPERTIES:\n:ID: %\\1\n:Time-stamp: <>\n:END:\n#+TIT..." ensure-newline)
  org-roam-capture--setup-target-location()
  org-roam-capture--prepare-buffer()
  org-capture-set-target-location(nil)
  #<subr org-capture>(nil nil)
  apply(#<subr org-capture> (nil nil))
  (let ((+file-templates-inhibit t)) (apply fn args))
  +file-templates-inhibit-in-org-capture-a(#<subr org-capture> nil nil)
  apply(+file-templates-inhibit-in-org-capture-a #<subr org-capture> (nil nil))
  org-capture(nil nil)
  org-roam-capture-(:goto nil :info nil :keys nil :templates nil :node #s(org-roam-node :file nil :file-title nil :file-hash nil :file-atime nil :file-mtime nil :id "2cebe412-371f-466d-84dc-471e31c57351" :level nil :point nil :todo nil :priority nil :scheduled nil :deadline nil :title "YY" :properties nil :olp nil :tags nil :aliases nil :refs nil) :props (:immediate-finish nil :call-location #<marker at 51102 in config.org>))
  org-roam-capture(nil)
  funcall-interactively(org-roam-capture nil)
  command-execute(org-roam-capture)

Thanks for any help.

I think the problem is that your org-capture id prompt %^{id} is not inside the template being filled out so org-capture has no way to replace the %\\1.

Based on https://www.orgroam.com/manual.html#The-Templating-System you should be able to replace the occurrences of both %^{id} and %\\1 with ${my-id} and have org-roam-capture ask you for the ID.

Thanks! Replacing with ${my-id} instead of %^{my-id} solve the issue. I had to put it three times because the operator %\\1 doesn’t work, but it’s fine for me.

Thanks again!