• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Complex Commission Formulas

Community Beginner ,
Jun 17, 2021 Jun 17, 2021

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";

TOPICS
Create PDFs , Edit and convert PDFs , JavaScript , PDF forms

Views

792

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 17, 2021 Jun 17, 2021

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)

Votes

Translate

Translate
Community Expert ,
Jun 17, 2021 Jun 17, 2021

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?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 18, 2021 Jun 18, 2021

Copy link to clipboard

Copied

LATEST

I was getting a Syntax Error, but everything is resolved now. Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Don't use spaces in variable names.

Change Total NDR to TotalNDR or Total_NDR.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 18, 2021 Jun 18, 2021

Copy link to clipboard

Copied

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2021 Jun 17, 2021

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 18, 2021 Jun 18, 2021

Copy link to clipboard

Copied

It works! Thank you so much!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines