- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2013 02:16 AM
Hello,
I am trying to set up a new UI Action called 'Send MTI Notification' on our incident form. When this button is clicked I want it to generate a pop-up window which contains the exact information that will go out in the email notification. Once the user hits the OK button, I want an event on the UI action to kick off the email notification and populates the email notification based on the pre-populated fields on the incident form.
I have already set up the UI Action button on the form that generates a 'Send MTI Notification' button when certain conditions are met. I have also set up the event 'incident.sendmtinotification', and an associated Notification, however I don't know which script I need on the UI Action in order to activate the event when the button is pressed.
If possible, can anyone please point me in the direction of the script I need to write, and also some information as to how I can create the popup window to preview the email before it is sent?
Thanks very much,
Charles
Solved! Go to Solution.
- Labels:
-
Analytics and Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2013 06:46 AM
Sure - these are the steps we took to get this up and running...
I have selected only the fields 'Incident Number', 'Short Description' and 'Causing System' on our Incident table for the example below -
These are the steps to set it up:
1) Go to UI actions, and create a new one for the email button . Enter a script based on the one below - Choose the values you want to add to the email (this is the top half of script - note that some fields require 2 lines of scripting to retrieve the values, if these are a choice/reference field, for example, such as 'u_causing_system') and the popup window (this is the bottom half of the script). Chose the name of your new popup window, and replace 'popup1' with this new name on the line 'var dialog = new GlideDialogWindow("popup1")'
....................................
function sendEmail(){
var incident_number = g_form.getValue("number"); var short_description = g_form.getValue("short_description");
var u_causing_system__value = g_form.getValue("u_causing_system_");
var u_causing_system_ = g_form.getOption('u_causing_system_',
u_causing_system__value).text;
//Initialize and open the Dialog Window
var dialog = new GlideDialogWindow("popup1"); dialog.setSize(1200,1200); dialog.setTitle("MTI Notification Preview - Incident In Progress");
dialog.setPreference("short_description", short_description); dialog.setPreference("incident_number", incident_number); dialog.setPreference("u_causing_system_", u_causing_system_);
dialog.render();
action.setRedirectURL(current);
}
....................................
2) Go to UI Pages and create your new popup window with your chosen title for 'popup1'. Enter a script based on the one below, and amend the values in the HTML script to match those shown in the UI action. The top of the HTML field retrieves the values shown in the UI action, and the bottom half presents these values onto the popup window. You can amend the format of the window here, along with the action buttons visible.
....................................
<?xml version="1.0" encoding="utf-8"?>
xmlns:g2="null">
expression="RP.getWindowProperties().get('short_description')" /> expression="RP.getWindowProperties().get('incident_number')" /> expression="RP.getWindowProperties().get('u_causing_system_')" />
value="${jvar_incident_number}"/>
Incident Title: ${jvar_short_description}
Incident Number: ${jvar_incident_number}
Causing System: ${jvar_u_causing_system_} id="send_email">Send id="cancel_button">Cancel
....................................
-The Client Script should be:
....................................
function onSubmit() {
//GlideDialogWindow.get().destroy();
return true;
}
function cancel() {
var c = gel('cancelled');
c.value = "true";
GlideDialogWindow.get().destroy();
return false;
}
....................................
-Then scroll down to the 'Processing Script':
....................................
var sysid = '';
var gr = new GlideRecord('incident');
gr.addQuery('number', inc_number);
gr.query();
if(gr.next()){
if (cancelled != "true") {
gs.eventQueue('XXXX', gr, gs.getUserID(), gs.getUserName()); } sysid = gr.sys_id; }
response.sendRedirect('incident.do?sys_id='+sysid);
gs.addInfoMessage('YYYY.');
....................................
-Amend 'XXXX' to be a new event name (eg, 'Email1') for the event to be called. Amend 'YYYY' to be the info message you want to be displayed when the email has been sent.
3) Go to the Registry and create a new event based on this, called XXXX or 'Email1'
4) Go to the Notifications section, and create a new notification based on the new event created in (3), making sure you select 'Event is fired:Email1/XXXX.
That should be it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 11:15 PM
Hi charles
My popup window is not coming.I have used the entire code provided by you but the window to send notification is not coming
Do i need to give any condition in onClick() ui Action button. Please respond fast
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2014 01:37 AM
Hi Charles,
can you send me the solution.
Regards,
Balaji Charapalli
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2014 01:47 AM
Hi Charles,
Could you please send me the steps or procedure to achieve this in our systems.
Thanks in advance....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2014 10:41 PM
Hey Charles,
Can you help me out on this. I just need to have a button on my incident form for escalating an incident. On clicking it an email should be trigerred.
Regards,
Kunika Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2014 03:50 PM
I had an objective of sending a notification via the click of a button so that it would go from my Service-Now and bounce into another instance thereby populating the data on said opposing side. Here is how I had gone about it.
You will need the following-
1. UI Action; 2. Registry Item; 3. Notification
1. UI Action
a. Name : Log with whomever
b. Table : Incident
c. Action Name : logwhomever
d. Ticked fields : Active; Show Insert; Show Update; Client; Form Context Menu
e. onclick : doConfirm();
f. Condition : ((current.u_logged != 'b3e3286f6f1e510066bb57fd5d3ee442') && (current.sys_updated_on != "") && (gs.hasRole("service_desk"))) //UI Action is to be used only once per record and limits the button to Service Desk users only
g. Script :
function doConfirm(){
if((g_form.getValue('assignment_group') == '') || (g_form.getValue('short_description') == '') || (g_form.getValue('description') == '')){
//ensures mandatory fields are completed before sending
g_form.hideFieldMsg('assignment_group');
g_form.hideFieldMsg('short_description');
g_form.hideFieldMsg('description');
g_form.setMandatory('assignment_group', true);
g_form.setMandatory('short_description', true);
g_form.setMandatory('description', true);
g_form.showFieldMsg('assignment_group','Assignment Group is a mandatory field.','error');
g_form.showFieldMsg('short_description','Short Description is a mandatory field.','error');
g_form.showFieldMsg('description','Description is a mandatory field.','error');
return false; //Abort submission
}
//Confirmation popup incase button is accidentally clicked
if(confirm('Are you sure you want to log this ticket with Whomever?')){
g_form.setValue("company", "b3e3286f6f1e510066bb57fd5d3ee442");
g_form.setValue("u_logged", "b3e3286f6f1e510066bb57fd5d3ee442");
gsftSubmit(document.getElementById('sysverb_update_and_stay'));
alert("Your job has now been forwarded");
}
else{
return false;
}
}
2. Registry Item
a. Event Name : incident.whomever
b. Table : Incident
c. Fired By : Log with whomever - UI Action
3. Notification
a. Name : whomever-Incident
b. Type : Email
c. Table : Incident
d. Send When : Event is fired
e. Event name : incident.whomever
And the rest of the email sections should be self-explanatory
Hope that helps some of you.