how to display a ui action button when clicking on other ui action button

raj765_32
Tera Contributor

hi can anyone help me with the scenario for 

 

there are two ui action buttons in purcgase order form

 

one is cancel and other is comform,

 

i want to display comform button only when cancel is clicked.

5 REPLIES 5

Asal Moezi
Tera Expert

Hi Raj,

The low-code way to achieve it, that came to my mind is to add a new True/False field on the table and keep it hidden. 

Then add to the Cancel UI action a line of code to  set the value of the new field to True. That would be something like this:

 

 g_form.setValue('u_new_field', true);
current.update();

 

Then add this to the condition of the second UI action, Conform:

 

current.u_new_field == 'true' 

 

 

Some notes: Make sure your company is ok with adding a new field to the table and then choose a meaningful name for the field.

 

I hope this helps!

but cancel is not a field , its a ui button, i want to show comform button ony when cancel is clicked.please see the screen shot

Ankur Bawiskar
Tera Patron
Tera Patron

@raj765_32 

UI actions are shown/hidden based on UI action condition and condition is evaluated only once when form loads.

Why not have proper UI action condition in both the UI actions to show them only when you want it to be visible?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Peter Bodelier
Giga Sage

You really do not want to mess around with the way UI actions are displayed.

As already suggested, please use the normal conditions of the UI Action to display it.


Therefore you might use a 'helper' field that can be set by the confirm UI Action, and then leveraged by the cancel UI Action, if you do not already have some other field on which you can base your logic.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.