Skip to main content
Known Participant
July 1, 2022
Question

Adobe DC converting a Matrix to Javascript to return a certain result

  • July 1, 2022
  • 2 replies
  • 514 views

I am a very basic user of Javascript and I think I am trying to do something way beyond my experience. I have a Risk Assessment Form and would like to have some information automatically returned when two different items are selected from two different dropdown boxes

From Dropdown1 someone selects the Likelihood that an event will occur (A, B, C, D, E) = rarely, unlikely, possible, likely, almost certain. Then from Dropdown2 selects the Consequences of the event happening (1,2,3,4,5) = Insignificant, Minor, Moderate, Major, Catastrophic.

Once the second item has been selected I would like a result to be automatically returned in a read only field called Rating:

E.g.: A + 1 = Very Low 

And so on for all of the options as per the matrix below.

Am I correct in assuming that this can only be done using an array or arrays and if so how?

 

Any help you can give would be greatly appreciated.

    This topic has been closed for replies.

    2 replies

    Nesa Nurani
    Community Expert
    Community Expert
    July 1, 2022

    As custom calculation script of "Rating" field use this:

    var str = this.getField("Dropdown1").valueAsString+this.getField("Dropdown2").valueAsString;
    switch(str){
    	case "A1": case "B1": case "C1": case "D1": case "E1":
    	event.value = "Very Low";
    	break;
    	case "A2": case "B2": case "C2": case "D2": case "E2":
    	event.value = "Low";
    	break;
    	case "A3": case "B3": case "C3": case "D3": case "E3":
    	event.value = "Medium";
    	break;
    	case "A4": case "B4": case "C4": case "D4": case "E4":
    	event.value = "High";
    	break;
    	case "A5": case "B5": case "C5": case "D5": case "E5":
    	event.value = "Extreme";
    	break;
    	default:
    event.value = "";}
    Known Participant
    July 4, 2022

    Nesa, you are a legend that worked wonderfully I will have to make a couple of changes to make sure the correct event value is returned, but that should be easy enough to do. Thank you so very much. 🙂

    Bernd Alheit
    Community Expert
    Community Expert
    July 1, 2022

    What export values does you use at the dropdowns?