UI Page not redirecting back to the source record
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2024 05:16 AM
I have configured an UI Page for closure survey which pops up on change of state to close in sn_customerservice_task Table. On submission of this survey, it should redirect to the task form and should store the response in the close notes of the task. It also should insert a record in a custom table to store the responses.
But my script isn't redirecting and it says the following:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<response>
<error>
<detail>null</detail>
<message>Requested URI does not represent any resource</message>
</error>
<status>failure</status>
</response>
Posting my client script and UI Page scripts for reference. Please help!
CLIENT SCRIPT - ONCHANGE OF State field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if (g_form.getValue('state') == '3' && (g_form.getValue('short_description').indexOf('SMOKE') || g_form.getValue('short_description').indexOf('Smoke') || g_form.getValue('short_description').indexOf('smoke') ) ) {
var url = top.location.href;
if (url.includes('now/cwf/agent')) {
var fields = [{
type: 'choice',
name: 'smoketest',
label: 'Did the smoke test failed?',
value: ' -- Select -- ',
choices: [{
displayValue: 'Yes',
value: 'yes'
},
{
displayValue: 'No',
value: 'no'
}
],
mandatory: true
}, {
type: 'textarea',
name: 'count',
label: 'How many times?[only fill,when "Did the smoke test failed?" is "Yes"]',
mandatory: false,
}, {
type: 'textarea',
name: 'errorcode',
label: 'What is the Error code occurred?',
mandatory: true,
}, {
type: 'textarea',
name: 'reason',
label: 'Reason for failure?',
mandatory: true,
}, {
type: 'choice',
name: 'configissue',
label: 'Is there any configuration Issue?',
value: ' -- Select -- ',
choices: [{
displayValue: 'Yes',
value: 'yes'
},
{
displayValue: 'No',
value: 'no'
}
],
mandatory: true,
}, {
type: 'choice',
name: 'api',
label: 'Is the API working as designed?',
value: ' -- Select -- ',
choices: [{
displayValue: 'Yes',
value: 'yes'
},
{
displayValue: 'No',
value: 'no'
}
],
mandatory: true,
},
{
type: 'choice',
name: 'sla',
label: 'SLA Breached?',
value: ' -- Select -- ',
choices: [{
displayValue: 'Yes',
value: 'yes'
},
{
displayValue: 'No',
value: 'no'
}
],
mandatory: true,
},
{
type: 'choice',
name: 'breachreason',
label: 'Reason for breach?[only fill,when "SLA Breached" is "yes"]',
value: ' -- Select -- ',
choices: [{
displayValue: 'Onboarding Team',
value: 'onb'
},
{
displayValue: 'L2 Support Team',
value: 'l2'
},
{
displayValue: 'L3 Support Team',
value: 'l3'
},
{
displayValue: 'Line Of Business',
value: 'lob'
},
{
displayValue: 'Integration Coordinator',
value: 'intcoord'
}
],
mandatory: false
},
{
type: 'textarea',
name: 'closenotes',
label: 'Close notes',
mandatory: true,
}
];
g_modal.showFields({
title: "Survey",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
var smoketest = fieldValues.updatedFields[0].value;
var count = fieldValues.updatedFields[1].value;
var errorcode = fieldValues.updatedFields[2].value;
var reason = fieldValues.updatedFields[3].value;
var configissue = fieldValues.updatedFields[4].value;
var api = fieldValues.updatedFields[5].value;
var sla = fieldValues.updatedFields[6].value;
var breachreason = fieldValues.updatedFields[7].value;
var tarRec = {};
tarRec.smoketest = smoketest;
tarRec.count = count;
tarRec.errorcode = errorcode;
tarRec.reason = reason;
tarRec.configissue = configissue;
tarRec.api = api;
tarRec.sla = sla;
tarRec.breachreason = breachreason;
tarRec.cstaskSYSID = g_form.getUniqueValue();
var ga = new GlideAjax('x_usbna_cf_csm.CFONBSmokeTest');
ga.addParam('sysparm_name', 'insertIntoSurvey');
ga.addParam("sysparm_targetRec", JSON.stringify(tarRec));
ga.getXML(function(response) {
var result = response.responseXML.documentElement.getAttribute('answer');
});
var closenotes = 'Close Notes : ' + fieldValues.updatedFields[8].value + '\n\n';
closenotes += 'Survey\n';
closenotes += '1) Did the smoke test failed? : ' + fieldValues.updatedFields[0].value + '.\n';
if (smoketest == 'yes') {
closenotes += '1a) How many times? : ' + fieldValues.updatedFields[1].value + '.\n';
}
closenotes += '2) What is the Error code occurred? : ' + fieldValues.updatedFields[2].value + '.\n';
closenotes += '3) Reason for failure? : ' + fieldValues.updatedFields[3].value + '.\n';
closenotes += '4) Is there any configuration Issue? : ' + fieldValues.updatedFields[4].value + '.\n';
closenotes += '5) Is the API working as designed? : ' + fieldValues.updatedFields[5].value + '.\n';
closenotes += '6) SLA Breached? : ' + fieldValues.updatedFields[6].value + '.\n';
if (sla == 'yes') {
closenotes += '6a) Reason for breach? : ' + fieldValues.updatedFields[7].value + '.\n';
}
g_form.setValue('close_notes', closenotes);
g_form.save();
});
}
var tableName = g_form.getTableName();
var caseNum = g_form.getValue('number');
var surveyPage = new GlideModal('x_usbna_cf_csm_CFONB-SmokeTestSurvey');
surveyPage.setTitle('SmokeTest Survey');
surveyPage.setSize(700, 400);
surveyPage.setPreference('sys_case_sys_ID', g_form.getUniqueValue());
surveyPage.setPreference('sys_table_name', tableName.trim());
surveyPage.setPreference('sys_case_number', caseNum.trim());
surveyPage.render();
}
}
UI PAGE HTML CODE:
<?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>
<body onload="hideFields()">
<g:evaluate var="jvar_sysId" expression ="RP.getWindowProperties().sys_case_sys_ID"/>
<g:evaluate var="jvar_tableName" expression ="RP.getWindowProperties().sys_table_name"/>
<g:evaluate var="jvar_caseNum" expression ="RP.getWindowProperties().sys_case_number"/>
<input type="hidden" id="contact_case_id" name="contact_case_id" value="${jvar_sysId}"/>
<input type="hidden" id="table_name" name="table_name" value="${jvar_tableName}"/>
<input type="hidden" id="case_num" name="case_num" value="${jvar_caseNum}"/>
<br/><br/>
<label for="smoketest"><b>Did the smoke test failed?</b></label>
<select class="form-select form-select-lg form-control" name='smoketest' id='smoketest' onChange="showHide(this)">
<option value="none" selected="selected">--None--</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br/>
<label for="count" id='count_label'><b>How many times?</b></label>
<textarea class="form-control" name='count' placeholder="Count : " id='count'/>
<br/>
<label for="errorcode" id='errorcode_label'><b>What is the Error code occurred?</b></label>
<textarea class="form-control" name='errorcode' placeholder="Error Code : " id='errorcode'/>
<br/>
<label for="reason" id='reason_label'><b>Reason for failure?</b></label>
<textarea class="form-control" name='reason' placeholder="Reason : " id='reason'/>
<br/>
<label for="configissue"><b>Is there any configuration Issue?</b></label>
<select class="form-select form-select-lg form-control" name='configissue' id='configissue'>
<option value="none" selected="selected">--None--</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br/>
<label for="api"><b>Is the API working as designed?</b></label>
<select class="form-select form-select-lg form-control" name='api' id='api'>
<option value="none" selected="selected">--None--</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br/>
<label for="sla"><b>SLA breached?</b></label>
<select class="form-select form-select-lg form-control" name='sla' id='sla' onChange="showHidereason(this)">
<option value="none" selected="selected">--None--</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br/>
<label for="breachreason" id='breachreason_label'><b>Reason for breach?</b></label>
<select class="form-select form-select-lg form-control" name='breachreason' id='breachreason' >
<option value="none" selected="selected">--None--</option>
<option value="onb">Onboarding Team</option>
<option value="l2">L2 Support Team</option>
<option value="l3">L3 Support Team</option>
<option value="lob">Line Of Business</option>
<option value="intcoord">Integration Coordinator</option>
</select>
<br/>
<label for="closenotes"><b>Close notes</b></label>
<textarea class="form-control" name='closenotes' placeholder="Close notes" id='closenotes'/>
<br/><br/>
<div class="modal-footer">
<span style="float:right">
<button class="btn btn-secondary" onclick="return cancelPage();">Cancel</button>
<button class="btn btn-primary" onclick="return submitRecord();" name="submit" id="submit" >Submit</button>
</span>
</div>
</body>
</g:ui_form>
</j:jelly>
UI PAGE CLIENT SCRIPT :
function cancelPage() {
GlideDialogWindow.get().destroy();
return false;
}
function submitRecord() {
var smoketest = gel('smoketest').value;
var count = gel('count').value;
var errorcode = gel('errorcode').value;
var reason = gel('reason').value;
var configissue = gel('configissue').value;
var api = gel('api').value;
var sla = gel('sla').value;
var breachreason = gel('breachreason').value;
var closenotes = gel('closenotes').value;
//alert(smoketest + count + errorcode + reason);
if (smoketest == 'none') {
alert('Did the smoke test failed? is Mandatory');
return false;
}
if (smoketest == 'yes' && count == ' ') {
alert('How many times? is Mandatory');
return false;
}
if (errorcode == ' ') {
alert('What is the Error code occurred? is Mandatory');
return false;
}
if (reason == ' ') {
alert('Reason for failure? is Mandatory');
return false;
}
if (configissue == 'none') {
alert('Is there any configuration Issue? is Mandatory');
return false;
}
if (api == 'none') {
alert('Is the API working as designed? is Mandatory');
return false;
}
if (sla == 'none') {
alert('SLA Breached? is Mandatory');
return false;
}
if (sla == 'yes' && breachreason == 'none') {
alert('Reason for breach? is Mandatory');
return false;
}
if (closenotes == ' ') {
alert('Close Notes is Mandatory');
return false;
}
return true;
}
function showHide(object) {
if (object.value == 'yes') {
gel('count').style.display = '';
gel('count_label').style.display = '';
} else {
gel('count').style.display = 'none';
gel('count_label').style.display = 'none';
}
}
function showHidereason(object) {
if (object.value == 'yes') {
gel('breachreason').style.display = '';
gel('breachreason_label').style.display = '';
} else {
gel('breachreason').style.display = 'none';
gel('breachreason_label').style.display = 'none';
}
}
function hideFields() {
gel('count').style.display = 'none';
gel('count_label').style.display = 'none';
gel('breachreason').style.display = 'none';
gel('breachreason_label').style.display = 'none';
}
addLoadEvent(function() {
hideFields();
});
UI PAGE PROCESSING SCRIPT:
gs.info("cstask1");
var smoketest = smoketest;
var count = count;
var errorcode = errorcode;
var reason = reason;
var configissue = configissue;
var api = api;
var sla = sla;
var breachreason = breachreason;
gs.info("SMOKETEST" + smoketest + count + errorcode + reason + configissue + api + sla + breachreason);
var closenotes = 'Close Notes : ' + closenotes + '\n\n';
closenotes += 'Survey\n';
closenotes += '1) Did the smoke test failed? : ' + smoketest + '.\n';
if (smoketest == 'yes') {
closenotes += '1a) How many times? : ' + count + '.\n';
}
closenotes += '2) What is the Error code occurred? : ' + errorcode + '.\n';
closenotes += '3) Reason for failure? : ' + reason + '.\n';
closenotes += '4) Is there any configuration Issue? : ' + configissue + '.\n';
closenotes += '5) Is the API working as designed? : ' + api + '.\n';
closenotes += '6) SLA Breached? : ' + sla + '.\n';
if (sla == 'yes') {
closenotes += '6a) Reason for breach? : ' + breachreason + '.\n';
}
gs.info("SMOKETEST" + closenotes);
var surIns = new GlideRecordSecure('x_usbna_cf_csm_cf_survey');
surIns.initialize();
surIns.did_the_smoke_test_failed = smoketest;
surIns.how_many_times = count;
surIns.what_is_the_error_code_occurred = errorcode;
surIns.reason_for_failure = reason;
surIns.is_there_any_configuration_issue = configissue;
surIns.is_the_api_working_as_designed = api;
surIns.sla_breached = sla;
surIns.reason_for_breach = breachreason;
if (case_num.startsWith('CSTASK')) {
surIns.cstask_number = contact_case_id;
}
var inSys_id = surIns.insert();
gs.info("SMOKETEST" + inSys_id);
var Rec = new GlideRecordSecure(table_name);
Rec.get(contact_case_id);
Rec.query();
Rec.next();
Rec.close_notes = closenotes;
Rec.state = 3;
Rec.update();
//response.sendRedirect(gs.getUrlOnStack());
response.sendRedirect("sn_customerservice_task.do?sys_id=" + contact_case_id);
0 REPLIES 0