How do I read a document's UID into a context variable?

I've tried:

Value: expr:@{Document[“uid:uid”]} in a Execution Context > Set Context variable (traindocuid) and get a blank(null?) when I use the traindocid variable in a User Interface > Add Info message as a check.

Message value is: traindocuid = @{traindocuid}. For the output, I get “traindocuid = " then nothing. No errors are generated on the screen or in the logs.

As a sanity check I substituted: expr:@{Document[“dc:title”]} in the Set Context Variable and this works as expected.

Am I missing something?

0 votes

3 answers

3805 views

ANSWER



Could it be related to the following bug https://jira.nuxeo.com/browse/NXS-908, fixed recently and released in the middle of next week on Studio ?

In short: Studio displays that the document HAS the uid schema while it is not the case. you could use another metadata or wait for the fix to be released.

0 votes



All the documents I'm trying to read are extended from Folder!

Followup Question: Why does Nuxeo Shell show, in my "folder extended" documents, a UID field populated with a number when I do a cat -all ?

01/20/2012

Are you sure they exactly inherit from Folder ? because you had said once that you had renamed the types imported with the initial default templates. If you have renamed it, it is not the same anymore, and you will have the above mentioned bug.

For your follow up question: the "uid" displayed with the cat command is not the uid:uid property but the doc ID. To display the doc ID in a layout configured with Studio, you can pickup in the schema "system", the field "Document ID"

01/21/2012

any update karl?
03/14/2012


Thanks for the help !!!!

Looks like expr:Document.getId() for value in Execution Context -> Set Context Variable get's me what I needed.

I didn't realize there was more that one uid property, the “system” uid is the uid I needed.

Karl

1 votes



btw, note, that the expr: in front of every expressions is useless (it is added automatically at processing time by studio if not present). Just use the @{Document.getID()}
01/24/2012


Could it be that in the first one you set up “traindocid” variable, while you try to read “traindocuid” (pay attention to the u)

0 votes



Good get! I checked, and the missing "u" is a typo in the question (I fixed the missing "u").

All seems well with the actual code.

The sanity check only replaces "uid:uid" with "dc:title" everything else is the same.

01/20/2012