Determine Which UI Action Control Was Used
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 10:39 AM
Hello all,
I have a server-side UI Action that has both the 'Form Context Menu' and the 'List Choice' controls checked.
Is there an easy way I can detect which one of these controls was used?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 10:40 AM
Hi Matthew,
You can use getActionName at client side to determine action name of UI action.
function onSubmit() {
var action = g_form.getActionName();
alert('You pressed ' + action);
}
http://wiki.servicenow.com/index.php?title=Getting_a_User_Object#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 10:46 AM
That would tell you the action name, but since this is available from both the form and the list, the action name will be the same. I was thinking there may be a g_list object or method that you could check. If it is undefined, you're on the form.
Maybe the inverse for g_form?
It's worth a try.
GlideForm (g form) - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 10:50 AM
You are correct Chuck . I got confused with the question. My bad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 11:46 AM
There is a g_list object which is available from a UI action when it's called from a list. Though it's only available client side so you will have to make sure it's a client UI action, do your check, then call the appropriate server code if needed.
GlideList2 (g list) - ServiceNow Wiki
Something like this inside your UI action should do the trick:
function myOnClickFunction() {
if (typeof g_list !== 'undefined') {
alert('Called from a list!');
} else {
alert('Called from a form!');
}
}