Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Calculation not recalculating on a change

Avatar

Former Community Member

The calculation below works for determining a late fee IF the user answers No to BOTH questions in fields "QSFiling" and "LateFeePd".  How do I have the late fee show 0 if the questions are any answer other No? OR when they might change from NO to a YES

 

if

(dataroot.Parent.SReport.QSFiling.rawValue ="No" && dataroot.Parent.SReport.LateFeePd.rawValue ="No"){dataroot.Voucher.LateFee.rawValue=

100;}

16 Replies

Avatar

Level 5

Hi,

you are wrong with the syntax.

= assigning a value

== is an equal operator

You have to write:

if (dataroot.Parent.SReport.QSFiling.rawValue  == "No" &&  dataroot.Parent.SReport.LateFeePd.rawValue == "No")

{

     dataroot.Voucher.LateFee.rawValue = 100;

}

This means:

IF the value from the field QSFiling No AND the value from the field LateFeePD No THEN should be the value of LateFee is 100.

Helpful?

Mandy

Avatar

Level 5

Hi,

Keep below script on calculate event of the LateFee field.

if( dataroot.Parent.SReport.QSFiling.rawValue == "No" && dataroot.Parent.SReport.LateFeePd.rawValue == "No")

{

               dataroot.Voucher.LateFee.rawValue=100;

}

else

{

               dataroot.Voucher.LateFee.rawValue=0;

}

Thanks

Vjay

Avatar

Former Community Member

I made that change however when I change the answer No to Yes or Yes to No it still does not recalculate, its sits with whatever I first answered in those fields.

Avatar

Former Community Member

Not working. Does it matter that the “LateFee” field is in the Voucher subform and the two questions are in my SReport form?

Avatar

Level 5

If you provide complete path of the fileds it doesnt matter.

Are you able to get LateFee = 100 ; if both the fields are "No"?

if you are getting then there might some issue with the script or the form settings.

Can you mail me the form muchukotavijay@gmail.com or you can share it here.

Thanks

Vjay

Avatar

Former Community Member

Good afternoon-

I hope you might still be available for assistance. When I run the script below in my LateFee field, it works if the two questions (QSFiling and LateFeePd) are answered NO.

However, if the user changes their initial answer from NO to YES the LateFee remains set at 100

dataroot.Fee.LateFee::calculate - (JavaScript, client)

if(dataroot.Parent.SReport.QSFiling.rawValue ="No" && dataroot.Parent.SReport.LateFeePd.rawValue ="No")

{

dataroot.Fee.LateFee.rawValue=100;

}

else

{

dataroot.Fee.LateFee.rawValue=0;

Avatar

Level 5

As

nele_sonntagsaid you are still using  Assignment Operators instead of using Comparison Operators.

Change your scrip to

if(dataroot.Parent.SReport.QSFiling.rawValue == "No" && dataroot.Parent.SReport.LateFeePd.rawValue == "No")

{

    dataroot.Fee.LateFee.rawValue=100;

}

else

{

    dataroot.Fee.LateFee.rawValue=0;

}

Thanks

Vjay

Avatar

Former Community Member

But everytime I do it as operators instead of comparisons it doesn’t even computer if the user answers No. Whereas, if I am using the comparison operators it at least computes if answers are no.

Form attached.

Does it matter that my two question fields are droplist

Avatar

Level 5

Goslinc,

please refer the below sample document.

https://workspaces.acrobat.com/?d=Xp7gmmvgWFsX6oL0G6c0mg

And what is the input are you giving."NO" or"No" or "no"?

Based on that u need to change the script.

Avatar

Former Community Member

Sorry I thought I did attach it, wondering if its not getting through to you.

Avatar

Former Community Member

Just wondering if you received my email with the form attached?

Thank you

Avatar

Level 5

Goslinc,

I didnt know that you are using DropDowns for the "QSFiling" and "LateFeePd".

Can you go to binding tab of "QSFiling" and "LateFeePd" fields and uncheck "Specify Item Values:" check box and try.

QSFiling > Object > Binding .... "Specify Item Values" . Do this for both dropdowns it will work.

If it doesnt work let me know vl share the file.

Thanks

Vjay