Problem
I want to get the value of a property of a org-contacts-db entry:
\* Example Contact :MYTAG: :PROPERTIES: :ID: foobar :END: With the function call (org-contacts-filter "Example Contact" nil nil) I get an alist of the contact "Example Contact" from the org-contacts-db, which looks something like
((#("Example Contact" 0 15 (fontified nil org-category "contacts")) #<marker at 14837 in contacts.org> (("CATEGORY" . "contacts") ("ID" . "foobar") … In order to get the value corresponding to the key "ID" I tried (cdr (assoc "ID" (org-contacts-filter "Example Contact" nil nil))), which only results in nil.
How do I get the value of the :ID: property?
Context
I want to build a capture template for events which can only take place at certain locations. Those locations and their addresses are all managed with org-contacts. The entries for the locations of interest share tagged the same. During the capture process I want to provide a list of locations, from which I can select the right one via the function my-capture-selection.
(defun my-capture-selection (list variable) "Let the user choose between a pre-defined set of strings" (make-local-variable variable) (let ((selected-value (ido-completing-read "Select from list: " list))) (set variable selected-value) selected-value)) To create the list I can search my org-contacts-db for all entries with a certain tag. (org-contacts-filter nil "MYTAG" nil) The result is something like:
((#("NAME_1" … )) … ("ID" . "ORG_ID_1") … (#("NAME_2" … )) … ("ID" . "ORG_ID_2") By calling %(my-capture-selection (org-contacts-filter nil "MYTAG" nil) 'my-selection)) in my capture template, I see all contacts tagged "MYTAG", select one of them and save the selection to "my-selection".
In order to provide a link to the org-contact for the location, I want to get the "ID" property, which was created with org-id. Since I already saved the name of the org-contacts-entry in "my-selection", I should be able to access any property of the entry. With access to the value of "ID" I could build a link to the entry with (concat "[[" …value of ID… "][" my-selection "]]")
org-id-get-- "Get the ID property of the entry at point-or-marker POM. ..."?