Monday, 24 August 2015

Populate same xml data in multiple fields

How to populate same xml data in multiple fields in LC Designer?

By design, the XML data tag can only be mapped to one field in the form. But still if you bind it with multiple fields then at the run time it fills that field which comes first in the occurrence.

The Global Binding is also not useful here. So the only option left is JavaScript.

Through JavaScript, we can assign the raw Value of multiple fields together.

In my example, I am using a Table to show multiple rows with data.

Populate Data

Snippet
var rowNodes = Table1.disqualifiedIndvDetails.instanceManager.count;

for (var nNodeCount = 0; nNodeCount < rowNodes ; nNodeCount ++)
{

     page2.Table2.disqualifiedIndvDetails.instanceManager.addInstance();
    page3.Table3.disqualifiedIndvDetails.instanceManager.addInstance();
   
    xfa.resolveNode("page2.Table2.disqualifiedIndvDetails["+nNodeCount+"].name").rawValue = xfa.resolveNode("Table1.disqualifiedIndvDetails["+nNodeCount+"].name").rawValue
    xfa.resolveNode("page2.Table2.disqualifiedIndvDetails["+nNodeCount+"].disReason").rawValue = xfa.resolveNode("Table1.disqualifiedIndvDetails["+nNodeCount+"].disReason").rawValue
    xfa.resolveNode("page2.Table2.disqualifiedIndvDetails["+nNodeCount+"].numMonths").rawValue = xfa.resolveNode("Table1.disqualifiedIndvDetails["+nNodeCount+"].numMonths").rawValue
   
    xfa.resolveNode("page3.Table3.disqualifiedIndvDetails["+nNodeCount+"].name").rawValue = xfa.resolveNode("Table1.disqualifiedIndvDetails["+nNodeCount+"].name").rawValue
    xfa.resolveNode("page3.Table3.disqualifiedIndvDetails["+nNodeCount+"].disReason").rawValue = xfa.resolveNode("Table1.disqualifiedIndvDetails["+nNodeCount+"].disReason").rawValue
    xfa.resolveNode("page3.Table3.disqualifiedIndvDetails["+nNodeCount+"].numMonths").rawValue = xfa.resolveNode("Table1.disqualifiedIndvDetails["+nNodeCount+"].numMonths").rawValue
}


 Source File: https://www.dropbox.com/s/1s0i3hoqzpnycsz/MultipleData.zip?dl=0

No comments:

Post a Comment