Expand my Community achievements bar.

Elevate your expertise and be recognized as a true influencer! Nominations for the exclusive Adobe Community Advisor program 2023 are now OPEN.

Dynamically populate text field based on result of on-the-fly calculation?


Level 2


I am attempting to create a hazard assessment form.

I have three drop-down lists, Exposure, Probability and Severity, respectively, that assign a numeric value to each of these.

Exposure can be ranked from 5 (most severe) to 1 (least severe).

Probabiliy can be ranked from 5 (most probable) to 1 (least probable).

Severity can be ranked from 10 (most severe), 5, 4, 3 and 2 (least severe).

Risk Cassification is a numeric field whose value is dynamically determined by calculating the sum of these three values. I have this as a calculate event in FormCalc, and the field is a numeric field set as Calculated - Read Only.

I would like to assign a text value to add context to the calculated value of the Risk Classification field. This is where I'm running into difficulty. I have a text field called Classification and it is set to Calculated - Read Only.

I've tried to do this using a variety of methods and events in FormCalc and also using the Action Builder. I haven't' had any luck.

Here's what I'm trying to accomplish:

Risk Classification (calculated on the fly)
Text to display

In other words, the numeric value of the calculation is displayed, and next to it, in a text field, I would also like to display the corresponding text for that rating.

I've referred to another post to come up with the following FormCalc code, invoked through a change/exit event on the Risk Classification field:

if (16 le $.rawValue le 20) then

     Classification = "Extreme";

elseif (11 le $.rawValue le 15) then

     Classification = "High";

elseif (6 le $.rawValue le 10) then

     Classification = "Moderate";

elseif (3 le $.rawValue le 5) then

     Classification = "Low";


     Classification = null;


As I say, to this point, this code does not work.

0 Replies


Level 10

Your syntax for figuring out the values is a little wonky. You need to test if the value is between two numbers so basically: if value >= lownumber AND value <= highnumber.

I would put the code on the Calculate event of the risk classification field - being as it is a calculated field the Change or Exit events aren't going to do anything.

(You don't need semicolons or rawvalue for FormCalc. $ equals "this" (the current field).)

if ($ ge 16 and $ le 20) then

     Classification = "Extreme"

elseif ($ ge 11 and $ le 15) then

     Classification = "High"

elseif ($ ge 6 and $ le 10) then

     Classification = "Moderate"

elseif ($ ge 3 and $ le 5) then

     Classification = "Low"


     Classification = null


Or you could put it on the Calculate event of the field that is holding the text, in which case you would change the $ to the name of the field that has the calculated number.

Haven't tested the above code but I think it should be correct.


Level 2

It works beautifully!

I've  kept the two separate: the calculation appears in the numeric field, while I've taken your suggestion and added your code to the text field and replaced the $ with the field name.

Thank you so much!