This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 12, 2013, 8:46 PM
9 Posts

Document Inheritance

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: Document Inheritance
  • Replies: 2
Is there any property to be set in XPAGES to allow the documents to inherit values from the parent document like checking "On Create: Formulas inherit values from selected document."
 
Only way to achieve this using the sessionScope variable for the fields from parent to child  and use it on page load of the child document or do we any other simple way to achieve this functionality?
 
 
Thanks.
Mar 12, 2013, 10:54 PM
586 Posts
Re: Document Inheritance
 There's no simple checkbox for document inheritance.  You do need to do it yourself.
 
Now in xpages I never use response documents.  I always use main documents and just use keys where needed.  
 
You don't need to use a scopeVariable if you're staying on the same page - you could pull from the main document directly in the new event of the related document. 
 
Probably a bunch of ways to do this... 
 
One way that should be convenient is to create a SSJS function.  pass in parentUNID and the new documentObject itself.  Then in that function get the parent with database.getDocumentbyUnid...  then just grab the values you want from the parent and put them on the new object.. 
 
That should work.  Guess I'd need to think of it more since there are different ways to do it.  I'm sure there are some examples on various notesIn9's ..
 
 
Dave 
Apr 22, 2013, 4:55 PM
10 Posts
Re: Document Inheritance
I too only use main documents.  Below is a simple example of one way to accomplish this:

 
Add a button labeled  'Create New Document' (this will reside on the Xpage considered the 'parent')

using simple actions do the following:
    Save the current document
    Store Note ID in a scoped variable:      sessionScope.put("parentNoteID",currentDocument.getNoteID());
    Open Page (to create the 'new' document): select name of page to open, set target document to New Document (in this case the 'childDoc')

In After Page Load Event:

    if(currentDocument.isNewNote()) {
                  var parentDoc=database.getDocumentByID(sessionScope.parentNoteID);
                  var childDoc=currentDocument;
                  fInherit(parentDoc, childDoc);                      // I store inherit function in a javascript library, sample code shown below
                   }


function fInherit(parentDoc, childDoc){
getComponent("Form").setValue("Exception_Form");   
var itemname = "Account_Bank";   
    getComponent(itemname).setValue(parentDoc.getItemValue(itemname));   
var itemname = "Bank_Abbrev";   
    getComponent(itemname).setValue(parentDoc.getItemValue(itemname));
var itemname = "Bank_Name";   
    getComponent(itemname).setValue(parentDoc.getItemValue(itemname));
var itemname = "Account_Branch";   
    getComponent(itemname).setValue(parentDoc.getItemValue(itemname));
 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal