Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Running Scripts

Avatar

Former Community Member
Hi,



I'm new to adobe, and I've been reading lots on this forum to get info on writing scripts in forms. I'm creating a form that has two pages, one for internal and one for our client.

I've written a couple things, and I was wondering what you do to run the script? I know in the sampler there is a button you push. Is there anyway to just get the calculations to automate?

For example, I need to do two things; 1. simple calculations within numeric fields and 2. Allow the text from one text field on the internal form to automatically enter itself in the text field on the external form (which I am stumped on).



a sample of one calculation I've written (in javascript) is below



var f = this.getfield("ProductSubtotal");

var g = this.getfield("Other");

var i = this.getfield("PercentDiscount");

event.value = (f.value + g.value)* (i.value/100)



It is supposed to create a product total from two numeric fields and add either a markup or discount. But when i switch to pdf preview it isn't working. (I've also tried saving the form and opening it in pdf).



Thanks a lot

Tiffany
2 Replies

Avatar

Level 7
Your script is very specific to forms created in Acrobat not LiveCycle Desinger. You should be aware that a field formatted as a percent displays 10.00% for 10 percent but has a value 0f 0.0010 in calculations.



For LiveCycle Designer you should be able to use the following FormCalc script to compute the amount of the discount assuming that the field "PercentDiscount" is the discount rate:



(ProductSubtotal + Other) * (PercentDiscount / 100)



To calculate the total you would need a FormCalc script like:



ProductSubtotal + Other + ( (ProductSubtotal + Other) * (PercentDiscount / 100) )

Avatar

Level 7
Or you can simplify the calculation:



(ProductSubtotal + Other) * ( 1 + (PercentDiscount / 100) )



Both scripts assume the discount rate is a negative number.