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

Need help writing a custom calculation script using if, then

New Here ,
May 17, 2023 May 17, 2023

My first time trying to creat a custom calculation script in an Adobe form and I need some help on writing a conditional script. If my weighted score (which is a percentage) is 1-49% then I want it to yield a "Low" priority score and if my weighted score is 50-74% then I want it to yield a "Medium" priority score and if my weighted score is 75-100% then I want it to yield a "High" priority score. Could you assist in writing the script? Also when I try to put the script in the Custom Calculation script box, I type in the script and then what? My options are Cancel or Go To Line, how do I get it to enter the script?

1.7K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
May 18, 2023 May 18, 2023

Use this as 'Custom calculation script' of "Text5" field:

var per = Number(this.getField("nSum").valueAsString);
if(per>=.01&&per<=.49)
event.value = "Low";
else if(per>=.5&&per<=.74)
event.value = "Medium";
else if(per>=.75&&per<=1)
event.value = "High";
else
event.value = "";

View solution in original post

Translate
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 ,
May 17, 2023 May 17, 2023

I've moved this from the Using the Community forum (which is the forum for issues using the forums) to the Acrobat forum so that proper help can be offered.

Translate
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 ,
May 17, 2023 May 17, 2023

If you only see 'Cancel' and 'Go To Line' try to resize JavaScript editor.

What are the names of the percentage field and the field where you want to show 'Low', 'Medium', 'High'?

How do you calculate percentage?

Translate
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
New Here ,
May 18, 2023 May 18, 2023

Hello,

 

Thanks in advance for your help.  I have copied and pasted below my form.  The weighted score is the product of “Sum of Total Score”, “Weight” which gives the “nSum”.  Then based on that percentage, I would like to assign a low, medium, or high score in “Text 5”

 

The priority score would assign Low, Medium or High based on: low (zero-49%), medium (50-74%), or high (75-100%).

 

 

DEE29938451e9aw_0-1684431981305.pngexpand image

 

 

 

 

Thank you also for the tip about resizing the JavaScript editor.  I was able to resize and found the “OK” button.

 

Translate
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 ,
May 18, 2023 May 18, 2023

Use this as 'Custom calculation script' of "Text5" field:

var per = Number(this.getField("nSum").valueAsString);
if(per>=.01&&per<=.49)
event.value = "Low";
else if(per>=.5&&per<=.74)
event.value = "Medium";
else if(per>=.75&&per<=1)
event.value = "High";
else
event.value = "";
Translate
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
New Here ,
May 18, 2023 May 18, 2023
LATEST

Thank you so much Nesa! I so appreciate your help in saving me hours of trying to figure this out!

Thank you, thank you , thank you!!!!!!!

 

Translate
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