xxf:document-id() - where does it get it from?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

xxf:document-id() - where does it get it from?

bwallis42
With reference to an old discussion, http://discuss.orbeon.com/unique-persistence-ids-td4659101.html, our persistence implementation replaces the orbeon generated document ID with our own ID and we also do a small translation of a form when it is saved to swapout the orbeon ID in the attached image and file URLs for our own ID.

This is all working beautifully with attachments to templates and forms and with saving of drafts with and without attachments. Everything works as expected... except one.

I've recently tried using the xxf:document-id() function in a form template to get the document ID and lo and behold, it returns the original Orbeon generated one.

Where is it getting this from? I don't store it via our persistence layer, it isn't in the form data file, it can't be in the template and our search function implementations always returns our IDs.

So where is orbeon getting this from? Is there some other form of persistence built into Orbeon that I am unaware of?

I would expect it to return my form ID as specified in the URL when I opened the form for display or edit.

I can get my ID by parsing the URL but I would rather not as that is rather messy.

(running 2016.3)

thanks,
brian...
Reply | Threaded
Open this post in threaded view
|

Re: xxf:document-id() - where does it get it from?

bwallis42
This post was updated on .
bwallis42 wrote
I can get my ID by parsing the URL but I would rather not as that is rather messy.
Actually, not as messy as I thought

xxf:split(xxf:split(xxf:get-request-path(),'/')[last()],':')[1]

Our ids are either nnnnnnnn or nnnnnnnn:mmmmmmmm and I want the nnnnnnnn part.

Reply | Threaded
Open this post in threaded view
|

Re: xxf:document-id() - where does it get it from?

Erik Bruchez
Administrator
In reply to this post by bwallis42
When a page loads, it creates a new form session, and an automatically-generated id is produced. This is stored internally in the objects which represent the running form. That's where `xxf:document-id() ` gets it from. This never appears on the URL (except for Form Runner PDF generation).

This is different from the Form Runner document id, by the way.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: xxf:document-id() - where does it get it from?

bwallis42
OK, Thanks. xxf:document-id() doesn't return what I thought it did. My xpath expression will do the trick.

thanks
brian...
Reply | Threaded
Open this post in threaded view
|

Re: xxf:document-id() - where does it get it from?

Erik Bruchez
Administrator
You might want to use `fr:document-id()` instead, if you are using Orbeon Forms 2016.2 or newer:

    https://doc.orbeon.com/xforms/xpath/extension-form-runner.html#frdocument-id

This will be more reliable.