Expand my Community achievements bar.

SOLVED

What is the best way to achieve this?

Avatar

Level 3

What is the best, way to do the following?

Form1 lists items that have a cost value

Form2 is an invoice form

What is the best way to export items with a cost value from form1 into form2?

A user would make item selections in form1 and save the form, then return it, or export data.

Then form2 would retrieve the item selections from form1 and display the cost values which I can sum up at the end of the form2.

Thanks in advance for any advice!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

If both forms have the same objects for the items and the same names, then an export to xml from form1 and importing xml into form2 should work.

Data in the xml that does not match the object names in form2 will be ignored.

In both forms the objects that you want to export/import must have their binding set to Normal/Name in the Object > Bindings tab.

Niall

View solution in original post

8 Replies

Avatar

Correct answer by
Level 10

Hi,

If both forms have the same objects for the items and the same names, then an export to xml from form1 and importing xml into form2 should work.

Data in the xml that does not match the object names in form2 will be ignored.

In both forms the objects that you want to export/import must have their binding set to Normal/Name in the Object > Bindings tab.

Niall

Avatar

Level 3

Thanks Niall, Just done a test, this works, but I seem to be having a problem calculating the total in form2?

Is this because the data in form2 has been imported into the form? The usual formcalc or js does not appear to work?

Tried both the below:

Sum (CostField1, CostField2)

Total.rawValue = CostField1.rawValue + CostField2.rawValue;

Thanks

Avatar

Level 10

Hi,

Here is a sample: https://acrobat.com/#d=PrU8BF5LIlk-lfloK1KjOQ

The main thing to check is that the script is in the calculate events and to include this line after the importData script:

xfa.form.recalculate(true);

This forces all calculate events to fire, thus updating values to take account of the imported XML values.

Note in the sample, not all of the objects have bindings. For example the Rate and Price columns are set to None binding in both files, therefore the values in the Import file come from the recalculate script.

Hope that helps,

Niall

Avatar

Level 3

Thanks, your example works great.

However, I tried to do this myself without using a table, and am still having problems summing up the total cost value?

Not sure what I am doing wrong?

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

Avatar

Level 10

Hi,

Can you check the URL and that the file is set to Share/Published.

I cannot access it at the moment:

Safari.png

I am out of the office this afternoon, so it may be the evening.

Niall

Avatar

Level 10

Hi,

Here is the form back to you: https://acrobat.com/#d=DQchSy3aBzl*Id51UO4QYQ

A couple of things:

  • The script was in the exit event of the dropdowns and this will not be called in the recalculate script. So I moved the script into the calculate event of the price fields.
  • The dropdown items were bound to '£123.59', this is a string and NaN. I know that you were using textfields for the price, but the Sum will not work. So I changed the bound values to "123.59' (a number) and changed the price fields to a numericField. You can set the display pattern in the Object > Field tab, just select Patterns and decide how you want the values to appear.
  • I set the binding for the price fields to None/No binding. Just to show that the calculate events fire. The only data coming across is the values from the three dropdowns.

I hope that helps,

Niall

Avatar

Level 3

Thanks Niall, that helps a great deal. I now understand where I went wrong!