Copy link to clipboard
Copied
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 🙂
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 = "";
Copy link to clipboard
Copied
For 'and' use &&
Copy link to clipboard
Copied
Thank you - I think I am getting closer but it is still giving a syntax error?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Working now! Thanks so much 🙂
Copy link to clipboard
Copied
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 = "";
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more