- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2022 04:28 AM
Hi all,
I have a UI action that calls a ui page this prompts a user to input a parent ticket which then closes that ticket with the parent copied to the field.
This works great thanks to
====
UI action code:
function commentsDialog() {
var gm = new GlideModal('Add Parent Reference');
gm.setTitle('Show title');
gm.setPreference('sys_id', g_form.getUniqueValue());
gm.render();
}
UI Page:
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');
alert('current.description');
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.u_request_close_code = "Duplicate Call";
app.state = '7';
app.update();
GlideDialogWindow.get().destroy();
}
window.open('/incident.do?sys_id='+sysId, '_self');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2022 04:36 AM
Hi,
you can send the description from UI action to UI page and update
function commentsDialog() {
var gm = new GlideModal('Add Parent Reference');
gm.setTitle('Show title');
gm.setPreference('sys_id', g_form.getUniqueValue());
gm.setPreference('short_description', g_form.getValue('short_description'));
gm.render();
}
UI Page
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')"/>
<g:evaluate var="jvar_shortDescription" expression="RP.getWindowProperties().get('short_description')"/>
<input type="hidden" id="cancelled" name="cancelled" value="false"/>
<input type="hidden" id="incidentSysID" name="incidentSysID" value="${jvar_sysid}"/>
<input type="hidden" id="incidentShortDescription" name="incidentShortDescription" value="${jvar_shortDescription}"/>
<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');
alert('current.description');
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";
var shortDesc = gel('incidentShortDescription').value;
// now use it
app.close_code = "Duplicate Call";
app.close_notes = "Closed as Duplicate";
app.u_request_close_code = "Duplicate Call";
app.state = '7';
app.update();
GlideDialogWindow.get().destroy();
}
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-20-2022 08:22 PM
Hi,
you need to discuss with customer whether they want work notes to be appended with short description or not
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader