Expand my Community achievements bar.

Data is not getting populated in the row after creating using addInstance() method

Avatar

Level 1

I've created a dynamic pdf via Livecycle Designer ES4. My requirement is to add rows dynamically to a table based on the no of test's in the xml file if there are more then one test in the xml file create the row dynamically and populate the test data into the cells. For the first row, data is getting populated in the table and from the second row onwards which is created using "addInstance()" method data is getting populated in the LiveCycle tool but it is displaying an empty row in the generated pdf in the application. Please find the below code :

GenericTemplateRequest.MainForm.ABNFormEnglishPatient.ABNTestsTable::initialize - (JavaScript, client)

var testNodes=xfa.datasets.data.GenericTemplateRequest.tests.resolveNodes("test[*]").length;

var testCnt = 0;

var medicareReason;

for(var i=0;i<testNodes;i++){

var abnFlag=xfa.datasets.data.GenericTemplateRequest.tests.nodes.item(i).sLCPFDAFlag.value;

if(abnFlag != "N"){

var sABNFlag = xfa.datasets.data.GenericTemplateRequest.tests.nodes.item(i).sLCPFDAFlag.value;

if(sABNFlag == "A")

{

medicareReason = 'Test Reason 1';

}

if (sABNFlag == "B")

{

medicareReason = 'Test Reason 2';

}

if(sABNFlag == "C")

{

medicareReason = 'Test Reason 3';

}

if(testCnt == 0){

GenericTemplateRequest.MainForm.ABNFormEnglishPatient.ABNTestsTable.ABNTestsRow.Laboratory Tests.rawValue = xfa.datasets.data.GenericTemplateRequest.tests.nodes.item(i).sTestCode.value+" "+xfa.datasets.data.GenericTemplateRequest.tests.nodes.item(i).sTestDesc.value;

GenericTemplateRequest.MainForm.ABNFormEnglishPatient.ABNTestsTable.ABNTestsRow.Reason.raw Value = medicareReason;

GenericTemplateRequest.MainForm.ABNFormEnglishPatient.ABNTestsTable.ABNTestsRow.Cost.rawVa lue = xfa.datasets.data.GenericTemplateRequest.tests.nodes.item(i).sTestCost.value;

}else{

var newRow = GenericTemplateRequest.MainForm.ABNFormEnglishPatient.ABNTestsTable.ABNTestsRow.instanceM anager.addInstance(i);

newRow.LaboratoryTests.rawValue = xfa.datasets.data.GenericTemplateRequest.tests.nodes.item(i).sTestCode.value+" "+xfa.datasets.data.GenericTemplateRequest.tests.nodes.item(i).sTestDesc.value;

newRow.Reason.rawValue = medicareReason;

newRow.Cost.rawValue = xfa.datasets.data.GenericTemplateRequest.tests.nodes.item(i).sTestCost.value;

}

testCnt++;

}

}

3 Replies

Avatar

Level 10

And what does the data look like you use? Please share a working sample of the form and data. Nobody has the time to build a new form from scrach to reproduce your problem.

Avatar

Level 1

Hi Radzmar,

https://github.com/vraamu/AdobeLiveCycleTestFiles/tree/master/Test

In the above link i uploaded the form, XML file and screenshots. I removed some of the contents from the form and XML due to confidential info after binding the form with xml when you click on "Preview PDF" tab in the second page data is getting populated in the second row of the table based on the condition but when i flatten the pdf using IText data is not getting populated in the second row of the table.

Avatar

Level 10

Well, the data and file ist fine so far. I don't know how iText works but you may have to save the form with the populated data first with Acrobat as LiveCycle Designers  does not include any data from the PDF preview. So, try to open the form in Acrobat, import your XML file, save the form and then process it with iText. Sorry, just guessing …