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 08:58 AM
Ok, after some testing in a personal dev, I found that this works, but it should be an "after" business rule:
var t = new GlideRecord('sc_task');
t.addQuery('request_item',current.request_item);
t.query();
var date = new GlideDateTime('1999-01-01 00:00:00');
while(t.next()){
var pd = t.u_planned_completion_date.getGlideObject();
if(date.getDisplayValue() == '1999-01-01 00:00:00'){
date = pd;
}
else if(t.u_planned_completion_date > date){
date = pd;
}
}
var r = new GlideRecord('sc_req_item');
r.addQuery('sys_id',current.request_item);
r.query();
if(r.next()){
r.due_date = date.getDisplayValue();
r.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2017 09:03 AM
PERFECT!! Thank you so much Kristen. I cannot tell you how much I appreciate all of the help!