- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 03:47 PM
We have a need to update the RITM Due Date after a SCTASK is closed(there is a date variable that is selected on this task). Once the date/time variable is selected, the task is closed, and we want the RITM Due Date to match the variable date/time selected. I put in a run script after that task is closed on the workflow but it's only setting the tasks that follow the 1st task to that due date. The RITM due date doesn't change.
Here's the run script:
current.due_date = current.variables.test_scan_target_date;
I was thinking I needed to use current.request_item.due_date = current.variables.test_scan_target_date; but that doesn't work at all and gives an error on the workflow.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 06:01 AM
Hello,
Firstly, please mark those replies above as Helpful, if they were...as you can see I did quite a bit of work on that.
Secondly, did the due date change? You didn't confirm that, but just said it "seems to let the run script work". As far as the tasks after it showing as cancelled, I'm not understanding how this run script has to do with that, but what you can also try to do is add a 1 second timer activity right after the run script to let the workflow breath for a second.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 04:27 PM
Hi,
Try using current.update() as below
current.due_date = current.variables.test_scan_target_date;
current.update();
Kindly mark my answer as Correct and Helpful based on the Impact.
Regards,
Alok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 04:58 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 03:56 PM
Thanks for the snipped of workflow, I believe the workflow itself was cancelled and due to which the pending activities got cancelled. I tried to replicate your scenario in my PDI and found that your script as below works fine.
current.due_date = current.variables.test_scan_target_date;
Could you please try using timer as suggested by Allen in other comment to 10 seconds after the run script and let the script update the RITM.
if above do not works then Could you please try without the Run script I believe its getting cancelled due to some other reason not for the runscript.
Also, I see that the If was the last activity which was executed so I suspect there may be something in if activity which cancels the entire workflow.
Kindly mark my answer as Correct and Helpful based on the Impact.
Regards,
Alok

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 06:50 PM
Hi,
Ok...a few things here:
1) You don't need to be doing current.update(); in a workflow runscript.
2) What table is this workflow running on? sc_req_item or sc_task? I would imagine sc_req_item...so those are the fields we are playing with. You shouldn't be doing anything with current.request_item.due_date, etc.
3) Can you show your exact script please? You've typed out and said what it is, but please show us specifically?
4) Is the variable a true date/time field and not just a date field? It must be date/time for this to work.
5) You have the run script highlighted above in the screenshot in green, so I assume it's the task right before it that the specific variable is being set on, correct? Can you also show a screenshot of the task with the variable on it, filled out?
6) Have you added any troubleshooting logs to your runscript to ensure it's actually running and also log what you're getting for: current.variables.test_scan_target_date?
I don't necessarily see why: current.due_date = current.variables.test_scan_target_date; wouldn't work if the variable is a date/time and all the other questions I have above are appropriately/correctly answered however...you could try this too:
var gdt = new GlideDateTime();
gdt.setValue(current.variables.test_scan_target_date);
current.due_date = gdt;
Again, I don't think you'd have to do this, but this will at least ensure that it's in the appropriate format for setting to that field.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!