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

Discount and Profit Calculation based on two drop down selections.

Community Beginner ,
Jun 09, 2022 Jun 09, 2022

Copy link to clipboard

Copied

I have one drop-down to select the market

one more drop-down to select the item.

A text field displays the value based on these two selections.

 

also, a text field to enter Qty.

Another text field for discount.

 

One more read-only text field displays the final price based on the first text field considering the Qty and the discount.

 

I need to show the profit as well.

Considering all the above, How do I do that.

 

 

Example of the query. (I am no JS expert, Apologies in advance)

If Market is UAE - ECP and Item is Item No1Profit = Offered Price - (Predefined Value * Qty)

 

I was thinking of something like below.

 

var mkt = this.getField("DP2").value;

var dev= this.getField(("Dropdown58").value;

var p1= Text32*1000

if (mkt=="UAE - ECP" && dev=="ZEISS Server") event.value = "text44"-p1

 

 

 

Please help me out. I am clueless.

TOPICS
PDF forms

Views

67

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 3 Correct answers

Community Expert , Jun 10, 2022 Jun 10, 2022

This should do what you asked for:

var mkt = this.getField("DP2").valueAsString;
var dev = this.getField("Dropdown58").valueAsString;
var p1 = Number(this.getField("Text32").value)*1000;
var p2 = Number(this.getField("Text44").value);
if(mkt=="UAE - ECP" && dev=="ZEISS Server")
event.value = p2-p1;
else
event.value = "";

Likes

Translate

Translate
Community Beginner , Jun 10, 2022 Jun 10, 2022

This worked for almost everything but for one.

Sharad_Ubeysinghe_0-1654862146935.png

First item line shows different outputs.

 

Can you please help.

Likes

Translate

Translate
Community Expert , Jun 10, 2022 Jun 10, 2022

You need to check field calculation order, select 'Prepare form' tool, click on 'More' then on 'Set field calculation order' and move "Text44" above "Text2" so it calculate first.

Likes

Translate

Translate
Community Expert ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

This should do what you asked for:

var mkt = this.getField("DP2").valueAsString;
var dev = this.getField("Dropdown58").valueAsString;
var p1 = Number(this.getField("Text32").value)*1000;
var p2 = Number(this.getField("Text44").value);
if(mkt=="UAE - ECP" && dev=="ZEISS Server")
event.value = p2-p1;
else
event.value = "";

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 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

This worked for almost everything but for one.

Sharad_Ubeysinghe_0-1654862146935.png

First item line shows different outputs.

 

Can you please help.

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 Expert ,
Jun 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

You need to check field calculation order, select 'Prepare form' tool, click on 'More' then on 'Set field calculation order' and move "Text44" above "Text2" so it calculate first.

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 10, 2022 Jun 10, 2022

Copy link to clipboard

Copied

LATEST

Yes it worked.

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