Setting Due Date Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2017 05:37 AM
I am attempting to set the due_date field on the catalog requested item form to pull from a user created field (u_planned_completion_date) on the sc_task table. Preferably, if the item has multiple tasks, it would use the last Planned Completion Date available. For some background, I'm doing this to override the auto-calculated "Expected Delivery Date of Completed Order" that the user sees when a request is submitted. I would like this to be blank until the work is planned and the Planned Completion Date field is filled.
I, honestly, don't even know where to start on this one. I'm not technically inclined, as I usually work on front-end, user experience with SNOW. Any and all help would be appreciated.
The closes thing I can think of would be something like:
task.due_date = current.variables.u_planned_completion_date;
But, I'm fairly certain that's not even close. I'm thinking it's going to have to be a more complicated client script.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2017 07:10 AM
Kristen,
So the due date field on the task (which I will probably hide when we go to production because it's not relevant) is populating with a date two months out. I do have a schedule currently set up on the item workflow, but the stage/task is only scheduled to take 14 business days. Now, looking back to some of the requests that I was testing before I tried your script, it was a "feature" that was happening before I added that business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2017 07:16 AM
Okay, so the only remaining issue is updating the requested item's due date based on the planned completion date? What type of field is the planned completion date? I noticed OOB, the due date is a date/time field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2017 07:19 AM
Correct. Planned Completion Date is a user created, date/time field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2017 07:20 AM
Hi Justin,
Just realized I missed a line of code (the update of the request item).
var t = new GlideRecord('sc_task');
t.addQuery('request_item',current.request_item);
t.query();
var date = '';
while(t.next()){
if(date == ''){
date = t.u_planned_completion_date;
}
else if(t.u_planned_completion_date > date){
date = t.u_planned_completion_date;
}
}
var r = new GlideRecord('sc_req_item');
r.addQuery('sys_id',current.request_item);
r.query();
if(r.next()){
r.due_date = date;
r.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2017 07:33 AM
So I tried that, and it altered the "Expected Delivery Date of Complete Order" on the user view of the request, which is good. However, when I fill out the Planned Completion Date field and update the task record, it is not updating or completing the Due Date field on the item. That field is now blank, which is making the "Estimated Delivery Date of Complete Order" also blank.