cancel
Showing results for 
Search instead for 
Did you mean: 

Attaching different scripts to different list entries in the drop down list

idarishoj
Explorer
0 Kudos

Hello!

I would like to use the drop down list as a way to run different scripts. So for example, when i choose "Timlønnet" i want to run a specific script, and a different script if i choose "Medarbejder i løntilskud". 

I think i would need to create a script for the "onSelect" event on the dropdown list that uses an If/else or maybe else/if method, but i have not been able to find an example here in the SAP Community about how to do this.

Hope you can help, thank you!

idarishoj_0-1707818971139.png

 

Accepted Solutions (0)

Answers (1)

Answers (1)

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

You're on the right track, and yes, you can do this. Here are the steps for an example:

  • Add your dropdown control to the flavor and insert the entries for the scripts you want to run. As key values, you could use something simple, like numbers 1,2,3 etc.
  • Add your scripts you want to run based on the dropdown selection. Note their ID, which you can find at the top of the script editor window. You can simply click on this to copy it into the clipboard:
    tamas_hoznek_0-1707870741463.png
  • Create a new script that drives the selection. The currently selected key value is provided in variable newKey
    The script could look something like this:

 

/* globals newKey */
var scriptNumber = newKey;
switch (scriptNumber) {
    case "1":
        session.utils.executeScript("wnd[0]/scrptPersonas_939100D454431EDEB2D9C6703D0C759A");
        break;
    case "2":
        session.utils.executeScript("wnd[0]/scrptPersonas_939100D454431EDEB2D9C8E52B7BB59A");
        break;
}​

 

Of course, you need to paste your own script IDs at the appropriate places.

  • Assign this new script to the onSelect event of your dropdown and it should work the way you wanted.