The CreatorCon Call for Content is officially open! Get started here.

Setting the due date via the workflow on all SC Tasks

Shamir Mawji
Kilo Expert

Hello all,

I am trying to set the due date on all tasks via the workflow. I have managed to do this for the RITM and the REQ.

Any ideas please? I am trying with the below code and it's not liking it using a run script before the tasks are created. 

var grCatTask = new GlideRecord('sc_task');
var gdtCatTask = current.variables.start_date;
current.due_date.setValue(gdtCatTask);

grCatTask.addQuery('sc_req_item', current.sys_id);
grCatTask.query();
if(grCatTask.next())

{

grCatTask.due_date = gdtCatTask;
grCatTask.update();

}

1 ACCEPTED SOLUTION

Angshuman3
Mega Guru

Hi Shamir,

Use the below code is each of the Catalog Task Activity, hope that would work :-


current.due_date = task.due_date;
var request = current.request.getRefRecord();
request.due_date = task.due_date;
request.update();

This code would update the due date value on REQ, RITM & SC_TASK forms.

Another Way :-

In the Run Script provide the below code :-

request.due_date = current.variables.start_date;
request.update();
current.due_date = current.variables.start_date;

And on each Catalog Task write this in the Advanced Section :-

task.due_date = current.variables.start_date;


This would also help.

Hope this helps.

Mark the answer as correct/helpful if you are satisfied.

Thanks,
Angshuman

View solution in original post

4 REPLIES 4

Mukesh Sharma
Giga Expert

I would say , rather than writing a script . You can set it in catalog task activity . you can either set it by out of the box set values feature or by clicking on advance and use the 'task' object to set any field of created task .  you can use your variable values as well . 

Please let me know if there is any doubts .. 

Please check the below screeshot

 

find_real_file.png

Angshuman3
Mega Guru

Hi Shamir,

Use the below code is each of the Catalog Task Activity, hope that would work :-


current.due_date = task.due_date;
var request = current.request.getRefRecord();
request.due_date = task.due_date;
request.update();

This code would update the due date value on REQ, RITM & SC_TASK forms.

Another Way :-

In the Run Script provide the below code :-

request.due_date = current.variables.start_date;
request.update();
current.due_date = current.variables.start_date;

And on each Catalog Task write this in the Advanced Section :-

task.due_date = current.variables.start_date;


This would also help.

Hope this helps.

Mark the answer as correct/helpful if you are satisfied.

Thanks,
Angshuman

Using the script below, can we add some type of formula that the due date on the task would be the Request/RITM due date plus 3 days?

 

current.due_date = task.due_date;
var request = current.request.getRefRecord();
request.due_date = task.due_date;
request.update();

This code would update the due date value on REQ, RITM & SC_TASK forms.

Shamir Mawji
Kilo Expert

Thanks all, I settled in the end for adding a line on each task.

task.due_date = current.variables.start_date;