Welcome Dialog

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

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

522

Likes

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

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

Translate

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

 

Likes

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!

Likes

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

Likes

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!

Likes

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

Likes

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!

Likes

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