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

How to return a text value based on selections in two drop down menus?

New Here ,
May 15, 2023 May 15, 2023

Hi, I am totally new to Acrobat pro and I'm working on my first ever fillable pdf. 

I'm wondering if anyone can assist me with a custom calculation script to calculate a risk rating please?

I have 3 drop down boxes, "Likelihood", "Consequences", and "Risk Rating". I want Risk Rating to return a value per the picture below, based on the selected values in "Likelihood", "Consequences". Eg, if "1 (Rare)" is selected in "Likelihood" and "1 (Insignificant)" is selected in "Consequences", then I want "Risk Rating" to return the text value "LOW".

I can't seem to fgure it out! Thanks in advance 🙂 

 

 

Victoria299032110dl1_0-1684209036217.png

 

TOPICS
Create PDFs , Edit and convert PDFs , General troubleshooting , How to , PDF , PDF forms
2.6K
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 15, 2023 May 15, 2023

You are using extra ( after every &&, just use parenthesis at the start and end of condition:

if(L=="1 (RARE)" && (C=="1 (INSIGNIFICANT)"||L=="1 (RARE)" && (C=="2 (MINOR)"||L=="1 (RARE)"...etc

 

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 15, 2023 May 15, 2023

Change "Risk Rating" field from dropdown to text field, and take a look at this:

https://community.adobe.com/t5/acrobat-discussions/risk-calculation-matrix/m-p/13779239#M411070 

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 15, 2023 May 15, 2023

Yeah I did already look at that but I can't get it to work since that is a table and mine is a picture. 

I tried below to start with but its saying "syntax error: missing) after condition" 

 

var L = this.getField("Likelihood").valueAsString;
var C = this.getField("Consequences").valueAsString;

if(L=="1 (RARE)" and (C=="1 (INSIGNIFICANT)"||L=="1 (RARE)" and (C=="2 (MINOR)"||L=="1 (RARE)" and (C=="3 (MEDIUM)"||L=="2 (UNLIKELY)" and (C=="1 (INSIGNIFICANT)"||L=="2 (UNLIKELY)" and (C=="2 (MINOR)"||L=="3 (POSSIBLE)" and (C=="3 (MEDIUM)")
event.value = "LOW";
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
Community Expert ,
May 15, 2023 May 15, 2023

For 'and' use &&

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 15, 2023 May 15, 2023

Thank you - I think I am getting closer but it is still giving a syntax error?

Victoria299032110dl1_0-1684213727053.png

 

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 15, 2023 May 15, 2023

You are using extra ( after every &&, just use parenthesis at the start and end of condition:

if(L=="1 (RARE)" && (C=="1 (INSIGNIFICANT)"||L=="1 (RARE)" && (C=="2 (MINOR)"||L=="1 (RARE)"...etc

 

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 15, 2023 May 15, 2023
LATEST

Working now! Thanks so much 🙂

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 15, 2023 May 15, 2023

This is what I have in full, but i don't really understand the syntax. can you use "and" to define two conditions? 

 

var L = this.getField("Likelihood").valueAsString;
var C = this.getField("Consequences").valueAsString;
if(L=="1 (RARE)" and (C=="1 (INSIGNIFICANT)"||L=="1 (RARE)" and (C=="2 (MINOR)"||L=="1 (RARE)" and (C=="3 (MEDIUM)"||L=="2 (UNLIKELY)" and (C=="1 (INSIGNIFICANT)"||L=="2 (UNLIKELY)" and (C=="2 (MINOR)"||L=="3 (POSSIBLE)" and (C=="3 (MEDIUM)")
event.value = "Low";
else if(L=="5 (ALMOST CERTAIN)" and (C=="1 (INSIGNIFICANT)"||L=="5 (ALMOST CERTAIN)" AND (C=="2 (MINOR)"||L=="4 (LIKELY)" and (C=="1 (INSIGNIFICANT)"||L=="4 (LIKELY)" AND (C=="2 (MINOR)"||L=="3 (POSSIBLE)" AND (C=="2 (MINOR)"||L=="3 (POSSIBLE)" AND (C=="3 (MEDIUM)"||L=="2 (UNLIKELY)" AND (C=="3 (MEDIUM)"||L=="2 (UNLIKELY)" AND (C=="4 (MAJOR)")
event.value = "Moderate";
else if(L=="5 (ALMOST CERTAIN)" AND (C=="3 (MEDIUM)"||L=="4 (LIKELY)" AND (C=="3 (MEDIUM)"||L=="4 (LIKELY)" AND (C=="4 (MAJOR)"||L=="3 (POSSIBLE)" AND (C=="4 (MAJOR)"||L=="3 (POSSIBLE)" AND (C=="5 (CRITICAL)"||L=="2 (UNLIKELY)" AND (C=="5 (CRITICAL)"||L=="1 (RARE)" AND (C=="5 (CRITICAL)")
event.value = "High";
else if(L=="5 (ALMOST CERTAIN)" AND (C=="4 (MAJOR)"||L=="5 (ALMOST CERTAIN)" AND (C=="5 (CRITICAL)"||L=="4 (LIKELY)" AND (C=="5 (CRITICAL)")
event.value = "Extreme";
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