how to canel or delete change task or sc_task at a time in the servicenow?

preddy1
Giga Expert

how to canel or delete change task or sc_task at a time in the servicenow?

6 REPLIES 6

HI,


we can write a script in both:

 

Below is a sample script:

 

var gr = new GlideRecord('sc_task');

gr.addQuery('request_item',current.sys_id);

gr.query();

while(gr.next())

{

//cancel here

gr.state = cancel state value it might be 4;

gr.update();

}


This BR is on RITM table and condition will be after update and if you want yoou can give extraa conditions as well like RITM state changes to Closed Incomplete, etc.

please test it properly.


Thanks,
Ashutosh

gregmelmoth
ServiceNow Employee
ServiceNow Employee

I assume that you are most concerned about the 'at a time' part of your request.

I assume that you mean after x Days or at a time specified on the task, you want the task to be cancelled/Deleted.

 

It very much depends on the situation as to how you would do this but there are a few options.
We would need to know more information to really assist further, how is this triggered? how long is the time period? is it tiggered at the same time every day or is the time defined dynamically or via a field on the task? 

 - You could add this into the workflow context using a Timer Activity, updating the record accordingly when the timer is met.

 - you could have a scheduled job that runs periodically looking for records that have reached the due date/time and then update/delete the given records. Similar to the Auto closure of incidents functionality that is OOB on incident table

 - failing that you could achieve this via scheduled events also,