Drop-down values from the field should populate the UI action.

Eswari K
Tera Contributor

Hi all, There is a field which contains five dropdown values. When i select the first value in the dropdown it should pop-up the UI action. In this scenario, I've created a client script but its reflecting error.

EswariK_0-1714039823209.png

EswariK_1-1714040126309.png

UI action

EswariK_2-1714040163731.png

 

 

1 ACCEPTED SOLUTION

ok , this is intresting for this you need to create a UI POLICY (ADVANCE SCRIPT)... See the below example.

create an UI Policy and change to the advanced view. {example logic given below}

 

Set the conditions that you normally would have on the UI Action. Make sure the "On load" & "Reverse if false" is checked like this:

 

SohailKhilji_0-1714043354820.png

 

 

And now for the magic to happen. Go into the Script section and check the Run scripts.

Put in the following code and as you can see we are using the action name as an identifier to find the UI Action and then simply using show() & hide() to make the button visible or not depending if the condition is true or not.

 

EDIT: This picture has been updated:

SohailKhilji_1-1714043354629.png

 

 

If you have been doing this in your dev you will now see that your button will hide and show depending if you change the priority to 1 or not.

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

8 REPLIES 8

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Eswari K getUIAction() is not a function in Servicenow. Plesae refer this Developer Doc https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/client/c_GlideFormAPI#r_GlideFo...

 

getActionName()

Returns the most recent action name, or, for a client script, the sys_id of the UI action clicked.
Returns
Type Description
StringThe current action name.

Example

 

function onSubmit() {
   var action = g_form.getActionName();
   alert('You pressed ' + action);
}

 

Regards,

Siddharam

 

Hi @Sid_Takali , Thanks for your response.

I tried it, but its not working fine!

 

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Eswari K ,

 

What do you mean by ''POP UP THE UI ACTION'' ? do you mean to say that you wanted to control the visiblity of the UI ACTION based on this fields value ?


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji, Thanks for you response

do you mean to say that you wanted to control the visiblity of the UI ACTION based on this fields value ?

Ans: Yes, In a fields there is a five dropdown values, when I select 1st value, then it should show the UI action button. If the user select 2nd value. then it shouldn't show the UI action button.