- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2014 03:56 PM
We have been working on the "New Call Plugin" and running into some issues determining which button was used to save/submit.
I am new to ServiceNow and am looking for an answer to this question, but will happily accept any alternate methods of accomplishing this task.
When saving the New Call Record, we want the save button to save the call record and allow the support analyst to stay on the same "New Call" page. If the submit button is clicked, we are looking for the application to take the end user directly to the ticket they just created.
In our current business rule, we are using this code to open the Incident/Request created by the New Call Plugin.
var sysID = gr.insert();
current.transferred_to = sysID;
var url = ctype + '.do?sys_id=' + sysID;
action.setRedirectURL(url);
This works great to open the Incident directly after clicking save or submit. I now need to be able to differentiate between which button the user clicks. I am trying to base this off of the ActionName of the UI Action. (We are using the OutOfBox save and submit buttons)
I created a Client Script which pops an alert box to tell me which is clicked, but getting the onSubmit Client Script and the on Insert business rule to work together doesn't seem like the best way to accomplish this. After some research, I found this link which tells me:
Identifying the action name in a business rule
This one probably isn't as common, but it's still handy to know when you need it. A script like the following could be used to identify the action name of the button clicked in a business rule…
gs.log(action.getActionName());
java.lang.SecurityException: Illegal access to method getActionName() in class com.glide.script.ActionDescriptor
Caused by error in Business Rule: 'CallTypeChanged' at line 77
74: }
75:
76:
==> 77: gs.log(action.getActionName());
78:
79: var sysID = gr.insert();
80: current.transferred_to = sysID;
------------------------------------------------------------------------------------
I was thinking if I can find out which button is being used I can determine how to handle moving forward. Example:
var buttonClicked = g_form.getActionName(); // Get Button that was clicked (This was coded for the Client Script)
if(buttonClicked == 'sysverb_insert_and_stay'){
action.setRedirectURL(url);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2014 06:18 AM
We ended up using UI Action Overrides on the Global Buttons so I didn't have to pass a variable to the business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2014 04:16 PM
It sounds like you are trying to have a UI Action run on the client side and then run certain code on the server side depending on the button. Is that right? If so, then maybe this is the right avenue to take: http://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
The relevant part of the code is this part:
if(typeOf window == 'undefined'){
//Anything run in here will be called on the server. You have access to current.
}
If you run server side code through your UI Actions like Mark's post says, then you don't have to try and figure out the name of the UI Action called because the server side action is called from each button.
Does this help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2014 06:14 AM
This was a helpful answer and it took me to a page that answered questions I didn't realize I had yet.
Thank you for the reply !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2014 06:18 AM
We ended up using UI Action Overrides on the Global Buttons so I didn't have to pass a variable to the business rule.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2015 09:48 AM
What did you end up putting in your Save button to make this work?
Thanks!