I am trying to get the parent document of a new response document so I can duplicate the functionality of form inheritance in xpages. The following is my code and the error being returned:
Error while executing JavaScript action expression
Script interpreter error, line=3, col=60: 'parentDoc' is null
JavaScript code
1: if (document2.isNewNote()) {
2: var parentDoc:NotesDocument = database.getDocumentByID(document2.getParentId());
3: getComponent("immediateParentSubject1").setValue(parentDoc.getItemValueString("Subject"));
4: }
I usually use a dataContext and getParentDocumentUNID() when I need a handle on the parent document for the variable “document”. You can use this for a new document (not saved yet):
You can then use parentDoc in other controls and do
parentDoc.getItemValueString("Subject")etc.