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

@sieusaopolo15 Create the ui action like this below, this will not be bypassed when users use keyboard shortcuts to save record.

 

jaheerhattiwale_0-1686638318445.png

 

jaheerhattiwale_1-1686638353245.png

 

Please mark as correct answer if this solves your issue.

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

@sieusaopolo15 

so what exactly you want to do when state changes?

write the same code in the BR

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

I want to abort action when user triggers events save from keyboard shortcut and I don't want it to run when UI Action "Save" is clicked because inside of that action has current.update() which can trigger the business rules.

@sieusaopolo15 

very difficult to identify if user is saving it using some keyboard shortcuts

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

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.