Copy link to clipboard
Copied
I need serious help. What I'm trying to say in my calculation is that if the Total Net Sales is between $50K and $80K, the Total NDR is multiplied by 15%; otherwise, anything below or higher than that will generate a $0 amount.
What am I doing wrong here?
var TNS = Number(this.getField("TNS").valueAsString);
var Total NDR = Number(this.getField("Total_NDR").valueAsString);
if (TNS<=50000&&TNS=>80000) event.value = Total NDR*0.15;
else event.value = "0";
There is couple of issue with your code.
1.You can't have variable name with space so change var Total NDR to var TotalNDR.
2.If you want to compare value between 50000 and 80000 then you need write higher then 50000 not smaller and smaller
then 80000 not higher,also you need to put first <= not =<. something like this: (TNS>=50000&&TNS<=80000)
Copy link to clipboard
Copied
Are you getting any errors?
If you open the debugger console (CTRL+J) what messages do you get when the script runs?
Copy link to clipboard
Copied
I was getting a Syntax Error, but everything is resolved now. Thank you!
Copy link to clipboard
Copied
Don't use spaces in variable names.
Change Total NDR to TotalNDR or Total_NDR.
Copy link to clipboard
Copied
Thank you!
Copy link to clipboard
Copied
There is couple of issue with your code.
1.You can't have variable name with space so change var Total NDR to var TotalNDR.
2.If you want to compare value between 50000 and 80000 then you need write higher then 50000 not smaller and smaller
then 80000 not higher,also you need to put first <= not =<. something like this: (TNS>=50000&&TNS<=80000)
Copy link to clipboard
Copied
It works! Thank you so much!