0
votes

I have an input field:

   <xp:inputText value="#{Cdoc.txt_UNID}" id="txt_UNID1"></xp:inputText>

The field txt_UNID is computed having the value: @Text(@DocumentUniqueID).

What I noticed is that even I just compose the xpage containing the document content the inputText already contains some UNID even if the xpage containing the doc content wasn't saved.

There is a button which is showing a dialog containing a field. I want this field to have the value of txt_UNID

Cdoc.save(); // I must save first the Cdoc datasource ?
getComponent('exampleDialog').show()

And the code for the field:

<xp:inputText value="#{Pdoc.txt_CompanieUNID}"
id="txt_CompanieUNID1" defaultValue="#{Cdoc.txt_UNID}">
</xp:inputText>

Thanks for your time.

2

2 Answers

1
votes

If your question is whether or not you must first save the document in order to get the UNID, my answer is yes. In my tests, the UNID has changed from a new document to a freshly saved document. So, yes if the current document is new, save before getting the UNID. At least when it was a NotesXspDocument.

I also generally use JavaScript for this,

cdoc.getDocument().getUniversalId();

Otherwise, I am unsure what you are asking.

0
votes

If PDoc is available at the same level of the hierarchy as CDoc, e.g. both are datasources assigned to the XPage / Custom Control or the same Panel, you could update PDoc on save, using PDoc.replaceItemValue("txt_CompanieUNID",Cdoc.getDocument().getUniversalID()). setValue should also work. Then you would not need the default value.

It just helps keep all business logic in one place. You could also check whether a value has already been set.