- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2019 06:56 PM
Hi All,
We are running Madrid Patch 4.
I am trying to create a UI Action that prompts the user to accept and then it triggers a notification using an event log.
I can get the event log working on its own(client=false), I can get the prompt to accept working on its own but I cant get both to work together.
Table - Contract
Client - True
Form link - True
Onclick - confirmAction()
Script -
I have tried the 2 below options and neither log the event(Again if i dont have the on click function the event logs without an issue)
Option 1
function confirmAction() {
var ans = confirm("Please confirm you want to email the contract owner to request an extension on this Contract");
if (ans == false){
return;
}
else
{
gs.eventQueue("Renewal contact email",current, current.renewal_contact,current.number);
}
}
Option 2
function confirmAction() {
var ans = confirm("Please confirm you want to email the contract owner to request an extension on this Contract");
if (ans == false)
return;
gs.eventQueue("Renewal contact email",current, current.renewal_contact,current.number);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2019 12:08 AM
Hello Nicole,
There is specific way to call Server side code and client side code in UI ACTION.
gsftSubmit(null, g_form.getFormElement(), "ui action id") triggers the UI Action which is specified in the 3rd parameter, which is the action name/element id.
It is mostly used in UI actions that have a client side and a server side script.
At the end of the client side script, you call gsftSubmit in order to trigger the UI Action again - this time running only the server side code.
Check this out for detailed information
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Your code should be something like this,
//Client-side 'onclick' function
function runClientCode(){
var ans = confirm("Please confirm you want to email the contract owner to request an extension on this Contract");
if (ans == false){
return;
}
else{
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), '<button_action_name>'); //MUST call the 'Action name' set in this UI Action
}
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode(){
//Check even name properly:
gs.eventQueue("Renewal contact email",current, current.renewal_contact,current.number);
action.setRedirectURL(current);
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2019 07:17 PM
Try this script. Make sure to add the action name to the script and confirm if your event name is correct. usually we dont add space to event names.
function confirmAction() {
var ans = confirm("Please confirm you want to email the contract owner to request an extension on this Contract");
if (ans == true)
{
gsftSubmit(null, g_form.getFormElement(), '<button_action_name>'); //MUST call the 'Action name' set in this UI Action
}
}
if(typeof window == 'undefined')
{
gs.eventQueue("Renewal contact email",current, current.renewal_contact,current.number);
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2019 07:26 PM
Hi,
Just to clarify, you are trying to trigger an event...not log an event.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2019 12:08 AM
Hello Nicole,
There is specific way to call Server side code and client side code in UI ACTION.
gsftSubmit(null, g_form.getFormElement(), "ui action id") triggers the UI Action which is specified in the 3rd parameter, which is the action name/element id.
It is mostly used in UI actions that have a client side and a server side script.
At the end of the client side script, you call gsftSubmit in order to trigger the UI Action again - this time running only the server side code.
Check this out for detailed information
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Your code should be something like this,
//Client-side 'onclick' function
function runClientCode(){
var ans = confirm("Please confirm you want to email the contract owner to request an extension on this Contract");
if (ans == false){
return;
}
else{
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), '<button_action_name>'); //MUST call the 'Action name' set in this UI Action
}
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode(){
//Check even name properly:
gs.eventQueue("Renewal contact email",current, current.renewal_contact,current.number);
action.setRedirectURL(current);
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2019 07:44 PM
Worked straight away!
Thank you very much