cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation script

Former Member
0 Kudos

Hi all,

I have a *.xdp template. I want to use some calculation scripts.

Scenerio:

I have 3 numerical fields:

1. Target quantity

2. Available quantity

3. Required quantity

I fill the data in # 1 with an xml. Then I generate the pdf with the above xdp and xml.

When the any user enters the Available quant i.e. # 2, I want to calculate # 3; which is:

$record.Detail[].reqdOrderQty0 = $record.Detail[].targetOrderQty0 - $record.Detail[*].availOrderQty0

I am using formCalc. On entring the Available quant and clicking somewhere else the reqd quantity should get calculated.

In which object should I put the script? and on which event?

Thanks,

Apurv

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Apurv,

I assume you have fields reqd, target and avail. These fields are in the same subform.

You should insert your code in calculate event of the field reqd. JavaScript (I don't use formcalc):

this.rawValue=target.rawValue-avail.rawValue;

If there will be a problem, insert following javaScript in change event of the field avail (sometimes calculate event isn't fired in complicated forms):

reqd.execCalculate();

Regards

Michal

Former Member
0 Kudos

Thanks Michal,

It worked.

Hi Amit,

I dont know why formCAlc didnt work. JavaScript did. But thanks a lot for your help.

    • Points assigned **

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Apurv

You can write the code on "Exit" event of the numeric field Available Quantity.

Regards,

Amit

Former Member
0 Kudos

Hi Amit,

That dosent work.

Here is what happens:

1) the above code in "calculate" of Available quantity >> changes itself and not required quantity

2) the one which you suggested, nothing happens.

Please suggest.

Thanks,

Apurv.

Former Member
0 Kudos

Hi Apurv,

$record.Detail[].reqdOrderQty0.rawvalue = $record.Detail[].targetOrderQty0 - $record.Detail[*].availOrderQty0

Write this on the "Exit" event of Available Qty. field.

Regards,

Amit