- 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-12-2016 07:28 PM
It probably is possible, but it's a lot harder to create a solution for. It adds more complexity when you try to update the record from the UI Page when there might be unsaved changes on the New Call form. This is just the easiest solution I could think off.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2021 11:13 PM
Hello,
Can someone please help? I have been searching on the web for many days, but I have no luck of finding an example of the below request.
I need a button on the incident form. When a user click on the button, a popup window with 4 checkboxes and a OK and Cancel buttons. If a user select one or all checkboxes, then click on the OK button. The select checkboxes information will populated in either the comment or work notes field on an incident form. If a user click on a cancel button, then it will close the popup window.
Thank you in advance