## Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.

• Complex Commission Formulas

# Complex Commission Formulas

Community Beginner ,
Jun 17, 2021 Jun 17, 2021

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

518

Likes

Report

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

Adobe Community Professional , 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)

Likes

6 Replies 6
Jun 17, 2021 Jun 17, 2021

Copied

Are you getting any errors?

If you open the debugger console (CTRL+J) what messages do you get when the script runs?

Likes

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 Beginner ,
Jun 18, 2021 Jun 18, 2021

Copied

LATEST

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

Likes

Report

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

Copied

Don't use spaces in variable names.

Change Total NDR to TotalNDR or Total_NDR.

Likes

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 Beginner ,
Jun 18, 2021 Jun 18, 2021

Copied

Thank you!

Likes

Report

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

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)

Likes

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 Beginner ,
Jun 18, 2021 Jun 18, 2021

Copied

It works! Thank you so much!

Likes

Report

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