Auto close ticket from RITM if another ticket on that RITM is closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 02:54 AM
Table = SC_REQ_ITEM
We have Walk Up Appointments configured that are linked to Request Items (Walk Up Appointment has RITM number associated with it as reference)
When the Walk Up Appointment is closed, we would like to close the final task associated with the same RITM, see below screenshot from RITM related lists the final task "Laptop for " to be closed if the Walk Up Appointment record is closed , no longer active
Is this possible via like a client script in Walk Up appointment record table to lookup request item task that starts with xxx and close it if the Walk Up Appointment is updated as inactive?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 03:14 AM
Hello,
Yes it is possible
You'll need to create the script include or server side script that performs the logic to find and close the final task associated with the RITM
This script will be referenced in the GlideAjax call in client script
Further in the client script below code can be used
(function () {
if(current.u_status =='inactive'){
var ga = new GlideAjax('CloseFinalTaskScript'); //Replace with you script include name
ga.addParam('ritm_sys_id', current.u_ritm_sys_id);
ga.getXMLAnswer(function (response) {
if (response == 'success') {
gs.print('task closed');
}
else{
return;
}
});
}
})();
Please mark my answer helpful, if it helped to find the solution
Thanks,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 03:21 AM
Thanks Priyanka, can you kindly share what the script include will look like or an example of similar logic to find a specific task in RITM and close it so I can customize it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 03:41 AM
Yes Sure,
Below is the script for script include:
var CloseFinalTaskScript = Class.create();
CloseFinalTaskScript.prototype = {
initialize: function() {},
closeFinalTask: function (ritmSysId) {
var finalTask = new GlideRecord ('u_task_table'); // Replace with the task table name
finalTask.addQuery ('ritm', ritmSysId);
finalTask.addQuery('active', true);
finalTask.orderByDesc('sys_created_on');
finalTask.query();
if(finalTask.next()){
finalTask.state = 3; //set the state to 'closed'
finalTask.update();
return "Success";
}
else{
return "No final task found";
}
},
type: 'CloseFinalTaskScript'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 04:51 AM
Please mark the above script as helpful if you could achieve the solution