- 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
‎06-23-2017 02:52 AM
After hours of researches I have finally found your posting how to solve my problem. Thank you so much for sharing your posting with the community! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 04:31 AM
Good to know it's proving helpful!
Ch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2015 04:02 PM
Good day,
How would this best be modified to affect any records on the Task table?
In your processing script you have a portion that created a new Incident record, and I am not quite sure how this plays into creating a notification event...
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 03:47 AM
Hi Shane,
This doesn't create a new incident, it just queries the table to obtain the incident number.
If you want to modify this for any record on the task table then just change the field names accordingly and it will be fine. If you want to use this on all tables extending from the Task table, then you'll probably need separate UI action scripts and Pages for each table, unless all the field names required on the UI page are exactly the same. The UI page will either hang or not appear at all if you try to generate values from fields that do not exist on the current form.
Cheers,
Charles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 09:23 AM
Thanks for the reply and info.
In my case, the Task extended information would always be the same: number and short_description.
UI Action code that I am trying for. Issue is redirecting the user back to the current record, as it currently redirects them to the UI page instead?:
Table: Task
OnClick: sendEmail();
Condition: current.active == true
Script:
function sendEmail(){
var number = g_form.getValue("number");
var short_description = g_form.getValue("short_description");
//Initialize and open the Dialog Window
var dialog = new GlideDialogWindow("uipagetaskfollowup"); dialog.setSize(600,600); dialog.setTitle("Request Follow-Up");
dialog.setPreference("short_description", short_description);
dialog.setPreference("number", number);
dialog.render();
action.setRedirectURL(current);
}
This is the code I am trying to use on the UI Page, please when you have a moment look through it and let me know if you see any issues. My questions are commented in to the code:
Main HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_short_description"
expression="RP.getWindowProperties().get('short_description')" />
<g:evaluate var="jvar_number"
expression="RP.getWindowProperties().get('number')" />
<g:ui_form>
<input type="hidden" id="cancelled" name="cancelled" value="false"/>
<input type="hidden" id="number" name="number" value="${jvar_number}"/>
<br/>
<table border='0' width="100%">
<tr>
<td valign="top"><span style='font-weight:bold;'>Title:</span></td>
<td valign="top">${jvar_short_description}</td>
</tr>
<tr>
<td><span style='font-weight:bold;'>Number:</span></td>
<td>${jvar_number}</td>
</tr>
<tr>
<td colspan='2'></td>
</tr>
<tr>
<td colspan='2' rowspan='2'>
<br/>
<g:dialog_button onclick="return onSubmit();" name="ok_button" id="send_email">Send Request</g:dialog_button>
<g:dialog_button onclick="return cancel();" name="cancel_button" id="cancel_button">Cancel Request</g:dialog_button>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function onSubmit() {
return true;
}
function cancel() {
var c = gel('cancelled');
c.value = "true";
GlideDialogWindow.get().destroy();
return false;
}
Processing Script:
var sysid = '';
var gr = new GlideRecord('task'); //query the task record, will this work?
gr.addQuery('number', number);
gr.query();
if(gr.next()){
if (cancelled != "true") {
gs.eventQueue('eventtaskfollowup', gr, gs.getUserID(), gs.getUserName()); } sysid = gr.sys_id; }
//How do I have this UI rendered "pop up" window close and then load the Task record at this point? This is running globally, so I can't force back to incident.do?*SYSID* or similar here.
gs.addInfoMessage('A follow-up request has been sent to the IT-ServiceDesk. If you do not hear back within a business day, please call the IT-ServiceDesk at ext 4444.');