# How to prevent \`org-roam-capture\` from adding ID property?

**URL:** <https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669>\
**Category:** Troubleshooting\
**Created:** [June 26, 2022, 3:35pm UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669 "2022-06-26T15:35:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablo](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/pablo/32/756_2.png) [@pablo](https://org-roam.discourse.group/u/pablo)\
**Post date:** [June 26, 2022, 3:35pm UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669/1 "2022-06-26T15:35:46Z")

</div>

The org roam capture template I rely upon to capture bibliographic notes creates a new file with an org heading, and places all relevant `PROPERTIES` in a drawer right below that heading, including an ID property. However, `org-roam-capture` appears to be set so that it always creates a file-level ID property, which results in an annoying and unnecessary proliferation of IDs. Here’s how a captured bibliographic note looks:

```nohighlight
:PROPERTIES:
:ID: 1DFCA536-6F58-4A8B-9E08-E7E580C706AD
:END:
#+title: Once we can see them, it’s too late

* Once we can see them, it’s too late
:PROPERTIES:
:ROAM_REFS: @Aaronson2021OnceWeCan
:URL: https://www.scottaaronson.com/blog/?p=5253
:NOTER_DOCUMENT: ~/Zotero/storage/MSBKIDU3/Aaronson2021OnceWeCan.pdf
:NOTER_PAGE: 
:ID: 70650C2F-B388-4EB9-B7EB-C3D3476A9E6C
:END:

```

As far as I can tell, there is no user option to change this behavior. The best I was able to do, with my extremely limited Elisp skills, is to tweak the `org-roam-capture-` function so that it does not insert a new ID value. But `org-roam-capture` still creates a file-level `PROPERTIES` drawer, with an `ID` key but no corresponding value, i.e.

```nohighlight
:PROPERTIES:
:ID:
:END:
#+title: Once we can see them, it’s too late

```

I would appreciate any guidance on how to change `org-roam-capture-` or other relevant functions so as to prevent `org-roam-capture` from creating this drawer altogether.

(Note that initially `org-roam-capture` was also inserting a `ROAM_REFS` property under the file-level drawer, but I solved this by setting `org-roam-capture-new-node-hook` to `nil`. See also related discussion [here](https://github.com/org-roam/org-roam/issues/1937) and [here](https://www.reddit.com/r/emacs/comments/rmcsue/adding_a_roam_ref_to_the_file_property_drawer/))

---

<div class="post-metadata">

**Author:** ![schemar](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/schemar/32/1158_2.png) [@schemar](https://org-roam.discourse.group/u/schemar)\
**Post date:** [June 26, 2022, 3:57pm UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669/2 "2022-06-26T15:57:13Z")

</div>

You can use org without org-roam to capture data which is not a roam node. Org roam requires IDs to identify its nodes. See also the documentation:

> **[Org-roam User Manual](https://www.orgroam.com/manual.html#The-Org_002droam-Node)**
>
> Org-roam User Manual

> An [org-roam] node is any headline or top level file with an ID.

---

<div class="post-metadata">

**Author:** ![pablo](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/pablo/32/756_2.png) [@pablo](https://org-roam.discourse.group/u/pablo)\
**Post date:** [June 26, 2022, 4:42pm UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669/3 "2022-06-26T16:42:12Z")

</div>

Hi, thanks. Yes, I am aware that org roam requires IDs to identify its nodes—I just don’t want the file itself, as opposed to the headings it contains, to be treated as a node.

Concerning using `org-capture` rather than `org-roam-capture`, the capture template is not invoked manually, but is rather triggered when certain at-point actions are selected using the `citar`, `embark` and `org-roam-bibtex` packages. I don’t think this behavior could be easily replicated with an `org-capture` template.

---

<div class="post-metadata">

**Author:** ![AuroraDraco](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AuroraDraco](https://org-roam.discourse.group/u/AuroraDraco)\
**Post date:** [June 27, 2022, 6:05pm UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669/4 "2022-06-27T18:05:48Z")

</div>

I have ventured in this domain in the past as well and from what I saw, it would be rather hard to remove this behaviour. You need to either use org-capture or live with the fact that this is the behaviour of org-roam-capture unfortunately.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [June 28, 2022, 6:15am UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669/5 "2022-06-28T06:15:34Z")

</div>

> [@pablo](#):
>
> Note that initially `org-roam-capture` was also inserting a `ROAM_REFS` property under the file-level drawer, but I solved this by setting `org-roam-capture-new-node-hook` to `nil`

Instead of setting it to `nil`, how about adding (appending to the end) a custom function to:

1. Remove `ROAM_REFS` property (e.g. `org-delete-property "ROAM_REFS`)
2. Check if the point is in the file property drawer, if so delete the ID property; leave it unchanged if point is in a headline (I think the point should be 1 if in the file property drawer, so the check should be trivial)

`org-delete-property` removes the entire property drawer when deleting the last remaining property, so you could have a clean Org file.

I don’t know how we can add a headline node; how do you do your capture to the headline of a file?

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [June 28, 2022, 9:48am UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669/6 "2022-06-28T09:48:50Z")

</div>

I do the following for my Md-roam to avoid Org-roam adding an Org-ID to the top of the file.

> <https://github.com/nobiot/md-roam/blob/main/md-roam.el#L207-L208>

My previous suggestion might be simpler to implement. I don’t use headline nodes, so you would need to adjust the code. This adds advice and then uses a hook to clean up the advice – yes, a bit convoluted but this is a technique Org-roam uses in some cases.

---

<div class="post-metadata">

**Author:** ![pablo](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/pablo/32/756_2.png) [@pablo](https://org-roam.discourse.group/u/pablo)\
**Post date:** [June 28, 2022, 4:29pm UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669/7 "2022-06-28T16:29:08Z")

</div>

Thanks, this works. The function I used:

```auto
  (defun ps/org-roam-remove-file-level-properties ()
    "Remove `ROAM_REFS' and `ID' properties from file-level drawer."
    (goto-char
     (point-min))
    (org-delete-property "ID")
    (org-delete-property "ROAM_REFS"))

```

There may be a more elegant way to do it, but this worked for me!

---

<div class="post-metadata">

**Author:** ![Gambhiro](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Gambhiro](https://org-roam.discourse.group/u/Gambhiro)\
**Post date:** [November 11, 2024, 5:29pm UTC](https://org-roam.discourse.group/t/how-to-prevent-org-roam-capture-from-adding-id-property/2669/9 "2024-11-11T17:29:28Z")

</div>

I found this thread when looking for information on how to stop the org-roam-dailies capture to insert an ID property for the week’s heading.

The solution is short but it was not obvious what org functions and hooks would work.

My notes are captured in a ‘week tree’, and by default an ID is created for the day heading such as ‘2024-11-11 Monday’.

I didn’t want these day headings to be included in the `org-roam-node-find` search results.

```lisp
(setq org-roam-dailies-capture-templates
      '(("d" "default" entry
         "* %<%H:%M> %?"
         :target (file+datetree "%<%Y-%m>.org" week)
         :tree-type week
         )))

```

```plaintext
* 2024
** 2024-W45
*** 2024-11-08 Friday
:PROPERTIES:
:ID: edd396e8-3c46-42b4-9417-a38318eeeeac
:END:
**** 19:00 some notes
**** 19:10 further notes
** 2024-W46
*** 2024-11-11 Monday
:PROPERTIES:
:ID: 52b75ae4-d69a-42d8-9eb4-3edef613d17e
:END:
**** 17:10 notes
**** 17:10 more notes

```

After some experimentation, the following function and hook worked.

```lisp
(defun gb/org-roam-dailies-capture-remove-id ()
  "When capturing a dailies note, remove the ID generated at the parent heading, such as '2024-11-11 Monday'."
  (when (org-roam-dailies--daily-note-p)
    (push-mark (point))
    (org-up-heading-safe)
    (org-delete-property "ID")
    (pop-to-mark-command)))

(add-hook 'org-capture-before-finalize-hook #'gb/org-roam-dailies-capture-remove-id)

```
