Expand my Community achievements bar.

SOLVED

If else not working in calculation

Avatar

Level 5

My form has a Final Total Approved Reimbursement field that should show the lesser of three fields but I cannot get it to work.  I've looked at it so long I can find no reason for it not to. It should be simple enough (that's probably the reason I don't see the error). Here's the code:

 

if (Number(bottom.tblCourse.row8.reimbApproved.rawValue) < Number(bottom.tblReimbRcvd.row3.cost2Dec.rawValue))
{
this.rawValue = (bottom.tblCourse.row8.reimbApproved.rawValue);
}
else if (Number(bottom.tblCourse.row9.proRatedApproved.rawValue < Number(bottom.tblReimbRcvd.row3.cost2Dec.rawValue))
{
this.rawValue = (bottom.tblCourse.row9.proRatedApproved.rawValue);
}
else {
this.rawValue = (bottom.tblReimbRcvd.row3.cost2Dec.rawValue);
}

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Please use the below-modified script, which worked for me.

 

if (tblCourse.row8.reimbApproved.rawValue < tblReimbRcvd.row3.cost2Dec.rawValue)
{
this.rawValue = tblCourse.row8.reimbApproved.rawValue;
}
else if (tblCourse.row9.proRatedApproved.rawValue < tblReimbRcvd.row3.cost2Dec.rawValue)
{
this.rawValue = tblCourse.row9.proRatedApproved.rawValue;
}
else {
this.rawValue = tblReimbRcvd.row3.cost2Dec.rawValue;
}

View solution in original post

10 Replies

Avatar

Community Advisor

Please check the somExpression of fields if they are resolving properly. This may be the reason or you can share your form @ (vkatoch07@gmail.com), I'll have a look.

Avatar

Level 5

My apologies.  I thought I had shared it but see it was blocked.  Here is the file.

Avatar

Correct answer by
Community Advisor

Please use the below-modified script, which worked for me.

 

if (tblCourse.row8.reimbApproved.rawValue < tblReimbRcvd.row3.cost2Dec.rawValue)
{
this.rawValue = tblCourse.row8.reimbApproved.rawValue;
}
else if (tblCourse.row9.proRatedApproved.rawValue < tblReimbRcvd.row3.cost2Dec.rawValue)
{
this.rawValue = tblCourse.row9.proRatedApproved.rawValue;
}
else {
this.rawValue = tblReimbRcvd.row3.cost2Dec.rawValue;
}

Avatar

Level 5

Unfortunately it is not working for me....In this instance $960 should be the "remaining FY Tuition Allowance.

 

ReluctantProgrammer_0-1697458587536.png

 

Avatar

Community Advisor

The script is working now, you can modify the logic as per your requirement

Avatar

Level 5

Can you possibly take a look and see if you can pinpoint what can be causing the issue?  I'm not even sure how/where to start.

Avatar

Administrator

@Vijay_Katoch Did you find the suggestions from Vijay helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 3

Hello,

 

Here is what I am seeing:

 

1. You are missing a ')' here: else if (Number(bottom.tblCourse.row9.proRatedApproved.rawValue< Number(bottom.tblReimbRcvd.row3.cost2Dec.rawValue))

2. You have a null variable error in your script object ColorFieldValidation, line 49:

TypeError: oOriginalNode is null

49:Doc:Init