Need to hide the closed state value in earlier change task not for the last task in change request
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
for a specific field choice list (4 choices) on change request we have CTASKs based on the short description (only string values and those created on same time after getting approvals). for the ctasks, need to hide the closed state value in earlier change task not for the last task in change request for this I written the client script and script include
Client script:
var currentTaskId = g_form.getUniqueValue();
var ga = new GlideAjax('ChangeTaskUtils');
ga.addParm('sysparm_name', 'isLastTask');
ga.addParm('sysparm_task_sysid', currentTaskId);
ga.getXMLAnswer(function(answer) {
if(answer === 'false') {
g_form.removeOption('state', '3');
}
});
}
script include:
var ChangeTaskUtils = Class.create();
ChangeTaskUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isLastTask: function() {
var taskSysId = this.getParameter('sysparm_task_sysid');
if(!taskSysId) return 'false';
var taskGR = new GlideRecord('change_task');
if(taskGR.get(taskSysId)){
var changeGR = new GlideRecord('change_request');
if(changeGR.get(taskGR.change_request)){
var decommType = changeGR.u_decommission_type + '';
var lastDesc = '';
if(decommType == 'bot decommission') {
lastDesc = 'DEPLOYMENT';
} else if(decommType == 'cost initiative project decommission') {
lastDesc = 'INFRA';
} else if (decommType == 'partial decommission') {
lastDesc = 'SECURITY AUDIT';
} else if(decommType == 'permanent decommission') {
lastDesc = 'SECURITY AUDIT';
}
if (taskGR.short_description.toString() == lastDesc) {
return 'true';
}
}
}
return 'false';
}
});
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
if it's not working then what debugging did you do?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader