Copy link to clipboard
Copied
I'm attempting to create a custom calculation script for a discount field (in $) where it takes the value of a master discount field (in %) times the quantity of the item by the price. The issue is that I have the master discount field set to be blank should no value be entered and this seems to interrupt the calculation. I'm quite inexperienced with javascript so I'd appreciate it if you could take a look at my issue and let me know what I might need to do in order to fix it.
This is the simple formula that I need to get the required total:
(QTY1*UnitPrice1)*(Discount1/100)
I am attempting to say that if the value = blank/null then do not perform the calculation otherwise perform (A*B)*(C/100):
if (this.getField("Discount1").valueAsString=="") then ???
else event.value = ( this.getField("QT1").value * this.getField("UnitPrice1").value ) * ( this.getField("Discount1").value / 100 );
Thank you!
if (this.getField("Discount1").valueAsString=="") event.value = "";
else event.value = ( this.getField("QT1").value * this.getField("UnitPrice1").value ) * ( this.getField("Discount1").value / 100 );
Copy link to clipboard
Copied
if (this.getField("Discount1").valueAsString=="") event.value = "";
else event.value = ( this.getField("QT1").value * this.getField("UnitPrice1").value ) * ( this.getField("Discount1").value / 100 );
Copy link to clipboard
Copied
Excellent, that worked perfectly! Thank you try67!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now