Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Few Data not save

Avatar

Level 5

only two fields data not save. I have placed a script it works fine but when open after saving file, the fields become empty. Why such happen?

calculation event:

var a = Itemnumber.rawValue;

var rowb = xfa.resolveNodes("form1.page2.Subform1.Table1.Row2[*]");

var rowc = xfa.resolveNodes("form1.page2.Subform2.Table1.Row2[*]");

var rowd = xfa.resolveNodes("form1.page2.Subform3.Table1.Row2[*]");

for (var i = 0; i < rowb.length; i++)

{

var b = rowb.item(i).Calculation.rawValue;

var bb = rowb.item(i).Total_dispensing.rawValue;

if(a==b)

var x= bb;

}

for (var i = 0; i < rowc.length; i++)

{

var c = rowc.item(i).Initial.rawValue;

var cc = rowc.item(i).Site2.rawValue;

if(a==c)

var y= cc;

}

for (var i = 0; i < rowd.length; i++)

{

var d = rowd.item(i).ActualPatients.rawValue;

var dd = rowd.item(i).Actual_patient.rawValue;

if(a==d)

var z = dd;

}

this.rawValue = x+y+z;

if(this.rawValue == 0)

this.rawValue ="";

in addition I am using acrobat X pro. another field data in same form get saved.

1 Accepted Solution

Avatar

Correct answer by
Level 10

I've extended my sample to handle the Actual_patient figures as well, so it now looks like;

if (!Itemnumber.isNull)

{   

    this.rawValue = 0;                          

    var rowb = xfa.resolveNode("form1.page1.subform2.Table2.Row2.(Calculation.rawValue == '"+Itemnumber.rawValue+"')");

    if (rowb !== null)

    {

        this.rawValue += rowb.Total_dispensing.rawValue;

    }

    var rowc = xfa.resolveNode("form1.page1.subform3.Table3.Row2.(ActualPatients.rawValue == '"+Itemnumber.rawValue+"')");

    if (rowc !== null)

    {

        this.rawValue += rowc.Actual_patient.rawValue;

    }  

}

And if Itemnumber can be duplicated then it would look like;

this.rawValue = 0;

if (!Itemnumber.isNull)

{

    var rowb = xfa.resolveNodes("form1.page1.subform2.Table2.Row2.(Calculation.rawValue == '"+Itemnumber.rawValue+"')");

    for (var i=0; i<rowb.length; i++)

    {

        this.rawValue += rowb.item(i).Total_dispensing.rawValue;

    }                                       

    var rowb = xfa.resolveNodes("form1.page1.subform3.Table3.Row2.(ActualPatients.rawValue == '"+Itemnumber.rawValue+"')");

    for (var i=0; i<rowb.length; i++)

    {

        this.rawValue += rowb.item(i).Actual_patient.rawValue;

    }  

}

I have updated my sample https://acrobat.com/#d=uQmAFWaVoHydJQ1Xtf0QhQ

I'm still not sure how the Itemnumber, Calculation and ActualPatient values are created in my sample you have to key them in, once keyed in the calculation match the expected output you posted.

Regards

Bruce

View solution in original post

17 Replies

Avatar

Level 10

Hi,

I not sure I properly understand your script, which form element calculate script is it under and what is Itemnumber?

Is it possible you can share the form (on Acrobat.com or similar)?

Regards

Bruce

Avatar

Level 5

Thanks for your reply. Many times I tried to access this page but I could not.

However,

4 tables containing add row function remains in a form. itemnumber and this (numeric field) column of same table. so itemnumber and numeric field remain in the same row and this row also increases.

If itemnumber of table 1 = itemnumber of table 2

corresponding value of table 2 will be added to numeric field of table 1.

same for other table.

above script is working well but it falls after reopening, during reopening numeric data is vanished.

I think you are clear now. You know well what is the perfect way to solve it. In addition other field data is being saved.

Avatar

Level 10

Hi

I'm still not sure I understand.  Are you saying the table with Itemnumber in is a total of Total_dispensing, Site2 and Actual_patient where Itemnumber matches Calculation, Initial and ActualPatients.  In this case you could try something like;

var rowb = xfa.resolveNode("form1.page2.Subform1.Table1.Row2.(Calculation.rawValue == "+Itemnumber.rawValue+")");

var rowc = xfa.resolveNode("form1.page2.Subform2.Table1.Row2.(Initial.rawValue == "+Itemnumber.rawValue+")");

var rowd = xfa.resolveNode("form1.page2.Subform3.Table1.Row2.(ActualPatients.rawValue == "+Itemnumber.rawValue+")");

this.rawValue = rowb.Total_dispensing.rawValue + rowc.Site2.rawValue + rowd.Actual_patient.rawValue;

This uses a predicate to match the row directly.  I'm not sure but suspect there would be something wrong with the dependency tracking of your initial approach.

Hope this helps, but suspect I wont be able to help more unless I can see the form.

Regards

Bruce

Avatar

Level 5

I have attached a form. I wished to show the actual form but I cannot share here. I think you understand it.

If you would see the attached file you could easily realize what I want.

If Itemnumber match with Calculation

else Total_dispensing value will be added to summation field.

How can I solved it?

Avatar

Level 10

I understand the problems of posting your form.  but have a look at the modified version of your form.  The code I added is in the calculate event of summation and looks like;


https://acrobat.com/#d=aKBzDp3am5cBkroisoxNEA


Note the som expressions are slightly different than your first sample.

Regards

Bruce

Avatar

Level 5

thanks for giving your valuable time.

Modified sample is not working.  error shows.

Would you tell what should I do now?

Avatar

Level 5

I have added code to remove error but I do not know this is the perfect way. error removed but no calculation in summasion field.

Avatar

Level 5

code is here

var a = xfa.resolveNodes("form1.page1.subform2.Table2.Row2[*]");

for(var i =0; i<a.length; i++)

{

if (!Itemnumber.isNull)

{

    var rowb = xfa.resolveNode("a.item(i).(Calculation.rawValue == "+Itemnumber.rawValue+")");

    if (rowb !== null)

    {

        this.rawValue = rowb.Total_dispensing.rawValue;

   

    }

}

}

Avatar

Level 10

I'm not sure I understand why you added to the for loop ... is it possible for more than one Calculation row to match an Itemnumber?  If so try this;

this.rawValue = 0;

if (!Itemnumber.isNull)

{

    var rowb = xfa.resolveNodes("form1.page1.subform2.Table2.Row2.(Calculation.rawValue == "+Itemnumber.rawValue+")");

    for (var i=0; i<rowb.length; i++)

    {

        this.rawValue += rowb.item(i).Total_dispensing.rawValue;

    }

}

Regards

Bruce

Avatar

Level 5

Hi,

I am thankful to you. Your given code should work for me but I do not get any result in summation field.

I have attached a file what is showing output. I have used color so that you can easily understand.

https://acrobat.com/#d=B3sphdsgtawL-tWWHypTFg

Regards

greennd

Avatar

Correct answer by
Level 10

I've extended my sample to handle the Actual_patient figures as well, so it now looks like;

if (!Itemnumber.isNull)

{   

    this.rawValue = 0;                          

    var rowb = xfa.resolveNode("form1.page1.subform2.Table2.Row2.(Calculation.rawValue == '"+Itemnumber.rawValue+"')");

    if (rowb !== null)

    {

        this.rawValue += rowb.Total_dispensing.rawValue;

    }

    var rowc = xfa.resolveNode("form1.page1.subform3.Table3.Row2.(ActualPatients.rawValue == '"+Itemnumber.rawValue+"')");

    if (rowc !== null)

    {

        this.rawValue += rowc.Actual_patient.rawValue;

    }  

}

And if Itemnumber can be duplicated then it would look like;

this.rawValue = 0;

if (!Itemnumber.isNull)

{

    var rowb = xfa.resolveNodes("form1.page1.subform2.Table2.Row2.(Calculation.rawValue == '"+Itemnumber.rawValue+"')");

    for (var i=0; i<rowb.length; i++)

    {

        this.rawValue += rowb.item(i).Total_dispensing.rawValue;

    }                                       

    var rowb = xfa.resolveNodes("form1.page1.subform3.Table3.Row2.(ActualPatients.rawValue == '"+Itemnumber.rawValue+"')");

    for (var i=0; i<rowb.length; i++)

    {

        this.rawValue += rowb.item(i).Actual_patient.rawValue;

    }  

}

I have updated my sample https://acrobat.com/#d=uQmAFWaVoHydJQ1Xtf0QhQ

I'm still not sure how the Itemnumber, Calculation and ActualPatient values are created in my sample you have to key them in, once keyed in the calculation match the expected output you posted.

Regards

Bruce

Avatar

Level 5

Thanks a lot. My 1st script was not perfect so it faild after saving.

You have created a perfect code. Now all going on well. You have spent your valuable time for me.

I am grateful to you.

you have apllied different code. I wish to know details. Would you tell me where I can know more.

var rowb = xfa.resolveNodes("form1.page1.subform2.Table2.Row2.(Calculation.rawValue == '"+Itemnumber.rawValue+"')");

Avatar

Level 10

The predicates are a powerful feature, John Brinkman has a blog on using them which would be a good start.  http://blogs.adobe.com/formfeed/2008/10/data_binding_with_predicates.html

I'm happy to have been able to help.

Regards

Bruce

Avatar

Level 5

Thanks for your kind help. I have gone through the artical. His blog is really awesome. However regarding sample is no longer exist. If I got those sample, it would be helpful to me.

regards

greenlnd

Avatar

Level 10

It would be worth asking John to fix his links, but I think these were the ones I downloaded when the blog can out;

predicate.pdf     https://acrobat.com/#d=*nGirOUgTI*q0lMZGuC5Hg

predicate2.pdf     https://acrobat.com/#d=b7cbgHU-1YGcxYVc7P9h3Q

inverted.xml     https://acrobat.com/#d=VFrLPW4isRSbDKglb8kMYA

John would be much more able to answer any questions about predicates than me and is very quick at responding.

Regards

Bruce

Avatar

Level 5

Great!!!

You have helped much. I am grateful to you. Best of luck!