Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to check if UI Action is fired from the form or list?

Tom Sienkiewicz
Mega Sage

Hi,

I have a Client UI Action that is available both as a form button and a list context menu.

What I' having trouble with is the gsftSubmit() function and any of the g_form functions are not available if run from e.g. a related list.

Do you guys (and gals) have any ideas how I might check from where the UI Action was triggered?

typeof rowSysId returns a value in both cases, so no use

g_form === undefined also does not seem to work.

I would like to write an if block so that if the UIA is triggered from a list it will run different client code than from a form.

Any help much appreciated,

Thanks!

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could just check the url of the frame for _list.


View solution in original post

5 REPLIES 5

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could just check the url of the frame for _list.


Right, haven't thought of that. thanks!


Hello Tomaz,



Though it seems you already have a solution, just wanted to share what I did for similar situation where I need to detect if a UI Action is fired from List Context or Form.



After lot of searching in Wiki and Community posts, I came up with below script to check and perform actions based on it:



gURI = action.getGlideURI();


var isList = gURI.get('sys_is_list');


var isRelList = gURI.get('sys_is_related_list');


if(isList || isRelList){


  perform list actions; //only if UI Action is fired from list or related list context menu


}else{


  perform form actions; //only if UI Action is fired from form view


}



Hope this helps!



Regards,


Santhosh


Thank you for this post from five years ago. It has really helped me today! This works great and is exactly what I need.