- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2025 12:10 AM
Dear Community,
I have a catalog item , after submission of this , it generates total 5 catalog tasks, what i want is when the 2nd task short description of task " Agreed date completed" is closed, i want to make future catalog tasks and RITMs variables read only.
I have tried this through UI policy and catalog client script but its not working. Any guidance would be really helpful!
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2025 01:23 AM - edited 12-16-2025 01:27 AM
you can use onLoad catalog client script + GlideAjax which runs on sc_task and sc_req_item
that will check if the 2nd task is closed or not
Script Include: It should be client callable
var YourScriptIncludeName = Class.create();
YourScriptIncludeName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkPreviousTaskClosed: function() {
var recordId = this.getParameter('sysparm_record_id');
var table = this.getParameter('sysparm_table');
var parent = null;
// Determine parent (RITM) based on table
if (table === 'sc_req_item') {
parent = recordId;
} else if (table === 'sc_task') {
var task = new GlideRecord('sc_task');
if (task.get(recordId)) {
parent = task.request_item;
} else {
return 'false';
}
} else {
return 'false';
}
// Get all tasks for the parent and check if the previous "Agreed date completed" task is closed
var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item', parent);
tasks.orderBy('sys_created_on');
tasks.query();
var foundCurrent = false;
while (tasks.next()) {
if (table === 'sc_task' && tasks.sys_id == recordId) {
foundCurrent = true;
continue;
}
if (!foundCurrent) {
if (tasks.short_description == 'Agreed date completed' && tasks.state == '3') {
return 'true';
}
}
}
return 'false';
},
type: 'YourScriptIncludeName'
});
onLoad Catalog Client Script: Which Applies on Applies on Catalog Tasks = True and Applies on Requested Items = True
function onLoad() {
var table = g_form.getTableName();
var recordId = g_form.getUniqueValue();
var ga = new GlideAjax('YourScriptIncludeName');
ga.addParam('sysparm_name', 'checkPreviousTaskClosed');
ga.addParam('sysparm_record_id', recordId);
ga.addParam('sysparm_table', table);
ga.getXML(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer === 'true') {
g_form.setVariablesReadOnly(true);
}
});
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Ankur,
I tried this but its not working. besides script include, do i have to separately write client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I will Suggest Use Flow Designer,
Steps :-
1) create the 5 cat tasks
2) look the record with short description "Agreed date completed"
3) Then use wait for condition and using data pill, If the look up record state is closed
4) Then make future cat tasks and RITM's read only by accessing ACL or triggering client scripts..
If you find this helpful mark this as helpful and also accept it as solution.
