- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 03:55 PM
Hello Team,
Got a challenge early in the morning. Hope you guys can help out.
- We have created a button called "Update Ticket" in a form called New Call (u_new_call).
- The new call form will take a few details from service desk and they will choose if the customer called in for a Incident or a Request and according to that a new record will be created in the Incident table or Request table respectively.
- If the customer called in regard to a previous ticket, the service desk has an option to enter the previous incident/request number and update the existing ticket.
- This is done when the customer enters the existing ticket number in a field (u_reference_number) and clicks on the "Update Ticket" button.
- Currently i got a prompt box running asking the service desk if they are sure they want to go ahead of the operation.
THIS IS THE CHALLENGE
- I want to be able to show a few details (Company, Short description) in the prompt box of the EXISTING TICKET before the service desks confirms.
All help is appreciated.
Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 06:00 PM
When you want to display some information in a popup window, there is the easy way to do it - with confirm(), or there is the nice/pro way to do it - with GlideDialogWindow.
http://wiki.servicenow.com/index.php?title=Displaying_a_Custom_Dialog#gsc.tab=0
I always like to make things look pro, so I use GlideDialogWindow (or GlideModal).
I'm assuming that when the Agent is completing the New Call form that they will not have saved the form before they click Update Task.
So I think the easiest solution will be to have a checkbox on your New Call form, called u_update_task. Then use the GlideDialogWindow to set the value of this checkbox and Save the New Call. When the New Call form is saved, a Business Rule checks the value of the checkbox, and updates the existing record if needed.
Add this Update task checkbox to the form - then hide it with a UI Policy. It must be in the form layout so that it can be updated with a Client Script.
The UI Action calls the GlideDialogWindow like this:
Name: Update Task
Client: true
onClick: getTicketInfo()
Script:
function getTicketInfo() {
var number = g_form.getValue('u_reference_number').toUpperCase();
if (!number) {
alert('Please enter a Reference number');
return;
}
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
var gm = new dialogClass('update_task');
gm.setTitle('Update Task');
gm.setWidth(600);
gm.setPreference('sysparm_number', number);
gm.render();
}
Create a UI Page:
Name: update_task
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 number = String(RP.getParameterValue('sysparm_number'));
var table = number.indexOf('INC') == 0 ? 'incident' : 'sc_req_item';
var taskType = number.indexOf('INC') == 0 ? 'Incident' : 'Request';
var task = new GlideRecord(table);
task.addQuery('number', number);
task.query();
</g:evaluate>
<j:if test="${!task.hasNext()}">
<p>Ticket not found</p>
</j:if>
<j:if test="${task.next()}">
<p>Are you sure you want to update this ${taskType}?</p>
<table>
<tr>
<td><b>Number:</b></td>
<td>${task.number}</td>
</tr>
<tr>
<j:if test="${table == 'incident'}">
<td><b>Caller:</b></td>
<td>${task.caller_id.getDisplayValue()}</td>
</j:if>
<j:if test="${table == 'sc_req_item'}">
<td><b>Requested for:</b></td>
<td>${task.request.requested_for.getDisplayValue()}</td>
</j:if>
</tr>
<tr>
<td><b>Category:</b></td>
<td>${task.category.getDisplayValue()}</td>
</tr>
<tr>
<td><b>Priority:</b></td>
<td>${task.priority.getDisplayValue()}</td>
</tr>
<tr>
<td><b>Short description:</b>$[SP]</td>
<td>${task.short_description}</td>
</tr>
<tr>
<td colspan="2" style="padding-top:20px;">
<button class="btn btn-primary" onclick="updateTask()" style="width:80px;">Yes</button>
<button class="btn btn-default" onclick="closeWindow()" style="width:80px;margin-left:20px;">No</button>
</td>
</tr>
</table>
</j:if>
</j:jelly>
Client Script:
function updateTask() {
g_form.setValue('u_update_task', 'true');
g_form.save();
}
function closeWindow() {
g_form.setValue('u_update_task', 'false');
GlideDialogWindow.get().destroy();
}
Then create an before insert/update Business Rule on the New Call table:
Condition: current.u_update_task.changesTo(true)
Script:
Update existing task
Probably close the New Call

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 06:00 PM
When you want to display some information in a popup window, there is the easy way to do it - with confirm(), or there is the nice/pro way to do it - with GlideDialogWindow.
http://wiki.servicenow.com/index.php?title=Displaying_a_Custom_Dialog#gsc.tab=0
I always like to make things look pro, so I use GlideDialogWindow (or GlideModal).
I'm assuming that when the Agent is completing the New Call form that they will not have saved the form before they click Update Task.
So I think the easiest solution will be to have a checkbox on your New Call form, called u_update_task. Then use the GlideDialogWindow to set the value of this checkbox and Save the New Call. When the New Call form is saved, a Business Rule checks the value of the checkbox, and updates the existing record if needed.
Add this Update task checkbox to the form - then hide it with a UI Policy. It must be in the form layout so that it can be updated with a Client Script.
The UI Action calls the GlideDialogWindow like this:
Name: Update Task
Client: true
onClick: getTicketInfo()
Script:
function getTicketInfo() {
var number = g_form.getValue('u_reference_number').toUpperCase();
if (!number) {
alert('Please enter a Reference number');
return;
}
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
var gm = new dialogClass('update_task');
gm.setTitle('Update Task');
gm.setWidth(600);
gm.setPreference('sysparm_number', number);
gm.render();
}
Create a UI Page:
Name: update_task
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 number = String(RP.getParameterValue('sysparm_number'));
var table = number.indexOf('INC') == 0 ? 'incident' : 'sc_req_item';
var taskType = number.indexOf('INC') == 0 ? 'Incident' : 'Request';
var task = new GlideRecord(table);
task.addQuery('number', number);
task.query();
</g:evaluate>
<j:if test="${!task.hasNext()}">
<p>Ticket not found</p>
</j:if>
<j:if test="${task.next()}">
<p>Are you sure you want to update this ${taskType}?</p>
<table>
<tr>
<td><b>Number:</b></td>
<td>${task.number}</td>
</tr>
<tr>
<j:if test="${table == 'incident'}">
<td><b>Caller:</b></td>
<td>${task.caller_id.getDisplayValue()}</td>
</j:if>
<j:if test="${table == 'sc_req_item'}">
<td><b>Requested for:</b></td>
<td>${task.request.requested_for.getDisplayValue()}</td>
</j:if>
</tr>
<tr>
<td><b>Category:</b></td>
<td>${task.category.getDisplayValue()}</td>
</tr>
<tr>
<td><b>Priority:</b></td>
<td>${task.priority.getDisplayValue()}</td>
</tr>
<tr>
<td><b>Short description:</b>$[SP]</td>
<td>${task.short_description}</td>
</tr>
<tr>
<td colspan="2" style="padding-top:20px;">
<button class="btn btn-primary" onclick="updateTask()" style="width:80px;">Yes</button>
<button class="btn btn-default" onclick="closeWindow()" style="width:80px;margin-left:20px;">No</button>
</td>
</tr>
</table>
</j:if>
</j:jelly>
Client Script:
function updateTask() {
g_form.setValue('u_update_task', 'true');
g_form.save();
}
function closeWindow() {
g_form.setValue('u_update_task', 'false');
GlideDialogWindow.get().destroy();
}
Then create an before insert/update Business Rule on the New Call table:
Condition: current.u_update_task.changesTo(true)
Script:
Update existing task
Probably close the New Call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 08:47 PM
Hi Geoffrey,
It seems to work and does what it has to do. Just a small issue, when i click on YES to update the task, it does not do anything. What i want it to do is, update the existing record and close the new call.
Hope you can help.
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2016 02:44 AM
It the last step. You need to create the Business Rule. It runs on the New Call record when the Update Task checkbox is ticked. Write your code in the Business Rule to update the existing record and close the New Call. I don't know the specifics of what you want to do to be able to provide the code. But it's the easiest part. It's just setting values on the current record, and using a basic GlideRecord to update the existing task.
Then create an before insert/update Business Rule on the New Call table:
Condition: current.u_update_task.changesTo(true)
Script:
Update existing task
Probably close the New Call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2016 03:03 PM
Hi Geoffrey,
Thank you so much for your help. Works perfectly. Just a quick question which i am curios about, Why do we need the checkbox for? Can we do the above tasks without the check? Just with the button?
Thank you
Regards