- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 07:28 AM
The use-case is to Populate certain values of Complaint Case to associated Complaint Task before the Complaint task is saved.
I have tried onChange of assignment group client script, calling GlideAjax:
Please find scripts below:
Client Script:
var group = g_form.getValue('assignment_group');
alert("GROUP :: " + group);
var cTaskNumber = g_form.getValue('number');
var choices = new GlideAjax('sn_complaint.BTComplaintCaseUtil');
choices.addParam('sysparm_name', 'getTemplateCompTask');
choices.addParam('sysparm_group', group);
choices.addParam('sysparm_task', cTaskNumber);
choices.getXML(getTemplate);
function getTemplate(response) {
console.log(response);
var answer = response.responseXML.documentElement.getAttribute("answer");
alert("ANSWER :: " +answer);
if (answer) {
g_form.setValue('description', answer);
}
}
Script include:
var BTComplaintCaseUtil = Class.create();
BTComplaintCaseUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getTemplateCompTask: function() {
var group = this.getParameter("sysparm_group");
var cTaskCmp = this.getParameter("sysparm_task");
var ctaskCmp = new GlideRecord('sn_customerservice_task');
cTaskCmp.addQuery('number', cTaskCmp);
//cTaskCmp.addQuery('assignment_group', group);
cTaskCmp.query();
if (ctaskCmp.next()) {
gs.info("SREESH @@@@ :: IN IF COMPLAINT TASK " + ctaskCmp.getEncodedQuery());
var cmp = new GlideRecord('sn_complaint_case');
if (cmp.get(ctaskCmp.parent)) {
gs.info("SREESH @@@@ :: IN IF COMPLAINT CASE" + ctaskCmp.parent);
var message = 'Related Account Number/Order Number: ' + cmp.getDisplayValue('company') + '\n' + 'Next Review Date: ' + cmp.getDisplayValue('due_date') + '\n' + 'Next KCI: ' + cmp.getDisplayValue('follow_up') + '\n' + 'Customer Contact Name: ' + cmp.getDisplayValue('contact') + '\n' + 'Customer Contact: ' + cmp.getDisplayValue('contact');
ctaskCmp.description = message;
ctaskCmp.update();
}
}
},
type: 'BTComplaintCaseUtil'
});
Any leads on this would be helpful 🙂
Thanks,
Sreesh Surendran
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 08:17 AM
you want to populate or you want to update?
update as this. you need to return the message
var BTComplaintCaseUtil = Class.create();
BTComplaintCaseUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getTemplateCompTask: function() {
var cTaskCmp = this.getParameter("sysparm_task");
var ctaskCmp = new GlideRecord('sn_customerservice_task');
cTaskCmp.addQuery('number', cTaskCmp);
cTaskCmp.query();
if (ctaskCmp.next()) {
var cmp = new GlideRecord('sn_complaint_case');
if (cmp.get(ctaskCmp.parent)) {
var message = 'Related Account Number/Order Number: ' + cmp.getDisplayValue('company') + '\n' + 'Next Review Date: ' + cmp.getDisplayValue('due_date') + '\n' + 'Next KCI: ' + cmp.getDisplayValue('follow_up') + '\n' + 'Customer Contact Name: ' + cmp.getDisplayValue('contact') + '\n' + 'Customer Contact: ' + cmp.getDisplayValue('contact');
ctaskCmp.description = message;
ctaskCmp.update();
return message;
}
}
},
type: 'BTComplaintCaseUtil'
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 08:17 AM
you want to populate or you want to update?
update as this. you need to return the message
var BTComplaintCaseUtil = Class.create();
BTComplaintCaseUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getTemplateCompTask: function() {
var cTaskCmp = this.getParameter("sysparm_task");
var ctaskCmp = new GlideRecord('sn_customerservice_task');
cTaskCmp.addQuery('number', cTaskCmp);
cTaskCmp.query();
if (ctaskCmp.next()) {
var cmp = new GlideRecord('sn_complaint_case');
if (cmp.get(ctaskCmp.parent)) {
var message = 'Related Account Number/Order Number: ' + cmp.getDisplayValue('company') + '\n' + 'Next Review Date: ' + cmp.getDisplayValue('due_date') + '\n' + 'Next KCI: ' + cmp.getDisplayValue('follow_up') + '\n' + 'Customer Contact Name: ' + cmp.getDisplayValue('contact') + '\n' + 'Customer Contact: ' + cmp.getDisplayValue('contact');
ctaskCmp.description = message;
ctaskCmp.update();
return message;
}
}
},
type: 'BTComplaintCaseUtil'
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:19 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 11:23 PM