When cancelling a request, what causes Tasks to close?

scottatah
Giga Expert

Hi Everyone,

When using the OOB Cancel UI Action on the sc_request, it cancels the Request, closes sc_req_items, closes, tasks, and cancels workflows.   My question is, what code is specifically closing the sc_tasks?  


I've been poking around for a bit, but I'm struggling to narrow it down.


Thanks,Scott

7 REPLIES 7

Hello Eduard G,



There is a business rule called "Close Tasks Due to Cancellations" which change the state of Tasks when request is cancelled.



We have one requirement when request is cancelled then its associated RITM and Task's state should also be set to Cancelled. But the thing is I am not able to find any code in Geneva instance which is changing the state of RITM.



Through cancel button I can change the state of Request. And for task's state change above B rule can be updated as required. But for request it automatically moves to "Closed Incomplete" but don't know how. I got some B rule which must be the cause but still did not find function.



request item closure --> have below code



// we just closed this requested item. Have to cancel its approvals


var reqItem = new SNC.RequestItem(current);


if (reqItem)


reqItem.cancelRelatedRecords();     --> I am not sure where this function comes from



Please reply if you find any solution.



Sneha Gadawe


Hi,



This function comes from the platform and it is not available for customisation.



Thanks,


Deepak.


PS: Hit like, Helpful or Correct depending on the impact of the response.


But if you really want to change the state to something else, then, you can change the state later by script:



// we just closed this requested item. Have to cancel its approvals


var request = new SNC.Request(current);


if (request)


  request.cancelRelatedRecords();


var req = new GlideRecord('sc_req_item');


req.addQuery('request', current.sys_id);


req.query();


while(req.next()) {


  req.state = 3;


  req.update();


}



Screen Shot 2016-09-22 at 1.55.18 PM.png


Change the code accordingly. This is just dummy code. Please verify before using.



Thanks,


Deepak.


PS: Hit like, Helpful or Correct depending on the impact of the response.