Get UI Action name at server script

sieusaopolo15
Tera Guru

Hi,

I want to get the UI Action name from the business rules when the users click on any UI Action on the table form like g_form.getActionName() at client scripts. How can I do that ? 

1 ACCEPTED SOLUTION

sieusaopolo15
Tera Guru

I will mark this answer as an "Accept as solution" because I have found an way to resolve this. For keyboard shortcuts saving the record I just create an business rules to detect the changes and for the UI Action, it needs clicking to process the script so I've put an constraint check if the fields which are inputted by users are not correct it will not run current.update() at the UI Action. With that I won't have to check if the button "Save" is clicked or not at business rules because solving this as an client script is easier than at business script.

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@sieusaopolo15 

why the requirement to get UI action name in business rule script?

Why not update the BR script in UI action script itself?

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

Hi @Ankur Bawiskar, the UI Action I'm checking is "Save" button, I need to know what events users trigger. Currently, I have found that if users use keyboard shortcuts to save the record the events in my UI Action can't run which is causing a lot bugs so that I need to create an BR script runs on update event but only runs when "state" field of that record changes but I don't want it to run at the same time when users click on "Save" button. That is my case, do you have any suggestion or better approach to check this ?

@sieusaopolo15 I think you need to create a save button on your table and with same action name as that of OOTB save button. Then add your logic to newly created save ui action.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

I did create an new UI Action for this and it's just the same. The UI Action only runs the script when we clicked on it, but in my case users use the keyboard shortcuts to save the record which bypass all the events in the "Save" UI Action