I want to write a script to update the due date

PRAGHATIESH S
Tera Expert

Hi,

In the RITM if i update the due date field, the SCTASK due date needs to automatically update the same.

Can anyone help here

1 ACCEPTED SOLUTION

sanketpatil09
Tera Guru

We can accomplish this by using Business Rules.

1. Navigate to Business Rules and select "Create New Business Rule."

2. Choose "Request Item" [sc_req_item] and set it as an After Business Rule.

3. In the "When to Run" section, select "Due Date is Modified." Then, write the script as follows:

 

(function executeRule(current, previous /*null when async*/) {

 

if (current.due_date != previous.due_date) {

var scTaskGr = new GlideRecord('sc_task');

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

scTaskGr.query();

 

while (scTaskGr.next()) {

scTaskGr.due_date = current.due_date;

scTaskGr.update();

}

}

})(current, previous);

 

  

View solution in original post

2 REPLIES 2

Mark Manders
Mega Patron

Where are you stuck on this? 

You can make a simple flow or BR on change of the due date, look up the sctasks and set that due date to the same.

 

What did you already try and what isn't working?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

sanketpatil09
Tera Guru

We can accomplish this by using Business Rules.

1. Navigate to Business Rules and select "Create New Business Rule."

2. Choose "Request Item" [sc_req_item] and set it as an After Business Rule.

3. In the "When to Run" section, select "Due Date is Modified." Then, write the script as follows:

 

(function executeRule(current, previous /*null when async*/) {

 

if (current.due_date != previous.due_date) {

var scTaskGr = new GlideRecord('sc_task');

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

scTaskGr.query();

 

while (scTaskGr.next()) {

scTaskGr.due_date = current.due_date;

scTaskGr.update();

}

}

})(current, previous);