
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 06:25 AM
Hi Team,
Could you please check, what I am missing in my UI Action Code.
Issue:
The prompt window is coming, but Notification is Not getting Triggered.
Requirement:
Table: SC_task, Need To have a Prompt window and if we enter some value, Notification will get trigger.
Code:
Regards,
Priya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 11:34 PM
Glad that it worked. Please mark answer as correct and helpful.
unfortunately you cannot send value of prompt box which user gave from client side to server side.
Also since you are not updating anything from server side just sending event you can make the UI action only client side
Approach below:
1) one user gives the email in prompt box; get the value
2) Write GlideAjax call in that client side code and pass the email, comments, record sysid
3) in the script include function updated the record using the sys_id and then get the email address given by user in prompt box and include that in event queue
Updated UI Action:
function promptUser(){
var con = prompt("Please enter some value to trigger notification");
if(con != null){
var ga = new GlideAjax('sendEmailUtils');
ga.addParam('sysparm_name', 'sendEmail');
ga.addParam('sysparm_email', con);
ga.addParam('sysparm_comments', 'Test test');
ga.addParam('sysparm_sys_id', g_form.getUniqueValue());
ga.getXML(processResponse);
function processResponse(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
}
}
else{
return false;
}
}
Sample Script Include: Client Callable
var sendEmailUtils = Class.create();
sendEmailUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
sendEmail: function(){
var email = this.getParameter('sysparm_email');
var comments = this.getParameter('sysparm_comments');
var sysId = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord('sc_task');
gr.get(sysId);
gr.comments = comments;
gr.update();
gs.eventQueue("onboard.welcome.event", gr,gr.request_item.variables.external_contact_email);
gs.eventQueue("onboard.welcome.event.pass", gr,gr.request_item.variables.external_contact_email);
},
type: 'sendEmailUtils'
});
Mark as Correct Answer & Helpful if this solves your issue or Helpful if this is useful to you.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 06:54 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 07:26 AM
Hi,
gs.event queue is not allowed in client script.
You need to change the code a bit:
Can you paste the code here not the image
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 07:40 AM
Hi
I am doing it in UI ACtion, and we do have one more Ui action wherein I am calling the same event and that is working fine(but that's not for Onclick Ui action).
Please find the below script:
function promptUser(){
var con = prompt("Please enter some value to trigger notification");
if(con != null){
g_form.setValue('comments', 'Test test');
gs.eventQueue("onboard.welcome.event", current,current.request_item.variables.external_contact_email);
gs.eventQueue("onboard.welcome.event.pass", current,current.request_item.variables.external_contact_email);
// gsftSubmit(gel('sysverb_update_and_stay'));
//gsftSubmit(gel('sysverb_update'));
}
else{
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 08:00 AM
Hi Priya,
few corrections
1) give action name to your UI Action - such as my_ui_action
2) updated script below
gs.eventQueue() is server side so it won't work in client side code; you need to use gsftSubmit()
then make the event trigger from server side code
function promptUser(){
var con = prompt("Please enter some value to trigger notification");
if(con != null){
g_form.setValue('comments', 'Test test');
}
else{
return false;
}
gsftSubmit(null, g_form.getFormElement(), 'my_ui_action'); // give here the action name
}
if(typeof window == 'undefined')
sendEmail();
function sendEmail(){
// server side code to trigger event
gs.eventQueue("onboard.welcome.event", current,current.request_item.variables.external_contact_email);
gs.eventQueue("onboard.welcome.event.pass", current,current.request_item.variables.external_contact_email);
}
Kindly mark correct & helpful if it helps.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader