Auto close ticket from RITM if another ticket on that RITM is closed

Ahmet1
Tera Expert

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

Ahmet1_1-1692870780743.png

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?

 

7 REPLIES 7

Community Alums
Not applicable

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

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?

Community Alums
Not applicable

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'

};

Community Alums
Not applicable

Please mark the above script as helpful if you could achieve the solution