- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2022 07:40 AM
Hi All,
We've been asked to create a ui action to close duplicate tickets in the incident table but when closed the advisor should be prompted to input the parent request ticket number if it's empty.
I've looked around and found various ways to do this but was hoping to seek advice here if someone has had something like this asked from their team?
I've tried using GlideModalV3 but honestly the documentation leaves much to be desired
Thanks all
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 05:29 AM
so your final code will be like this
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:ui_form>
<g:evaluate var="jvar_sysid" expression="RP.getWindowProperties().get('sys_id')"/>
<input type="hidden" id="cancelled" name="cancelled" value="false"/>
<input type="hidden" id="incidentSysID" name="incidentSysID" value="${jvar_sysid}"/>
<table>
<tr>
<td id="label.parent request" class="label" nowrap="true" height="23px" type="string" choice="0"><span id="status." class="mandatory label_description" mandatory="true" oclass="mandatory">$[SP]</span><label for="parent request" onclick="" dir="">Parent Ticket:</label></td>
<td nowrap="true"><g:ui_reference name="parent_request" id="parent request" table="incident"/></td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr><td align="left" nowrap="true"><br /><g:dialog_buttons_ok_cancel ok="return validateForm();" cancel="return onCancel();"/></td></tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function onCancel() {
var c = gel('cancelled');
c.value = "true";
GlideDialogWindow.get().destroy();
return false;
}
function validateForm() {
alert('inside validateform');
if (gel('parent_request').value == '') {
alert("${JS:gs.getMessage('Please input Parent Ticket')}");
return false;
}
else {
var sysId = gel('incidentSysID').value;
var parentValue = gel('parent_request').value;
var app = new GlideRecord("incident");
if(app.get(sysId)){
app.parent_request = parentValue;
app.incident_state = '7';
app.work_notes = "Closed as Duplicate";
app.close_code = "Duplicate Call";
app.close_notes = "Closed as Duplicate";
app.state = '7';
app.update();
}
window.open('/incident.do?sys_id='+sysId,'_self');
}
}
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
09-06-2022 08:21 AM
hey
so precessing script is just like a server side script so you can perform the server side code in this .
like lets says you want to post the selected number into work notes or populate it on any field on the form you can use processing script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2022 08:55 PM
Hi,
you are allowing user to select parent incident but it will be updated for which incidents?
Is this correct?
<g:ui_reference name="location" id="parent request" table="incident"/>
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
09-07-2022 03:09 AM
Hi Ankur,
The thought process here is the user needs to select an incident record that will fill the parent_request field on the incident form, so when the ticket is closed as a duplicate they are forced to put in the original ticket reference.
Is this correct? No - I've amended this to parent_request now thanks for spotting
<g:ui_reference name="location" id="parent request" table="incident"/>
<g:ui_reference name="parent_request" id="parent request" table="incident"/>
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 05:11 AM
Hi Ankur,
I'm still struggling with this i've created a UI action that calls the ui page but i can't get it to prompt the user just to input the parent request number to then update that field in the current ticket.
My UI Action:
table: Incident
Action name : comments_dialog
client - ticked
form button - ticked
OnClick- commentsDialog()
Script:
function commentsDialog() {
var gm = new GlideModal('Add Parent Reference');
//Sets the dialog title
gm.setTitle('Show title');
gm.setPreference('table', 'incident');
gm.setPreference('parent_request', 'value');
//Opens the dialog
gm.render();
}
=======
My UI Page:
Name: Add Parent Reference
HTML:
<g:ui_form>
<input type="hidden" id="cancelled" name="cancelled" value="false"/>
<input type="hidden" id="incidentSysID" name="incidentSysID" value="$"/>
<table>
<tr>
<td id="label.parent request" class="label" nowrap="true" height="23px" type="string" choice="0"><span id="status." class="mandatory label_description" mandatory="true" oclass="mandatory">$[SP]</span><label for="parent request" onclick="" dir="">Parent Ticket:</label></td>
<td nowrap="true"><g:ui_reference name="parent_request" id="parent request" table="incident"/></td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr><td align="left" nowrap="true"><br /><g:dialog_buttons_ok_cancel ok="return validateForm();" cancel="return onCancel();"/></td></tr>
</table>
</g:ui_form>
Client Script:
function onCancel() {
var c = gel('cancelled');
c.value = "true";
GlideDialogWindow.get().destroy();
return false;
}
function validateForm() {
if (gel('parent_request').value == '') {
alert("${JS:gs.getMessage('Please input Parent Ticket')}");
return false;
}
else {
return true;
}
}
Processing Script:
if (cancelled == "false") {
var grParentRequest = new GlideRecord ("incident");
grParentRequest.initialize();
grParentRequest.parent_request = request.getParameter("parent_request");
var grNewParentRequest = grParentRequest.insert();
gs.addInfoMessage("Ticket "+grParentRequest.parent_request+" Added.");
response.sendRedirect("incident.do?sys_id=" + incidentSysID);
}
First time doing this so if there is anyway you could assist either by tweaking my code or advising what i'm doing wrong?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 07:03 AM
Hi All,
I've made some advances i've been able to get the ui page to show for the request ticket now
i can search the incident table
however when i press ok i'm taken to this page and the field has not updated on the previous form
Edit: I've noticed after pressing OK it seems to create a blank incident ticket