The Now Platform® Washington DC release is live. Watch now!
‎11-03-2017 09:04 AM
In my catalog items, I have a field that asks users when they need their item by. Is there a way to link that variable to the delivery time? For example, if they said they needed it on November 17th (14 days from now), is there a way to have the delivery time show 14 days as well so that it matches their response? Or, is there a way to make the workflow recognize their response and match the due date to that? Would any of this be possible?
‎11-03-2017 11:25 AM
You can create a business rule on the sc_req_item table, before insert, to set the due date based on your variable.
‎11-03-2017 11:26 AM
Since due date is a date/time I believe and our forms only collect date, and we have a couple different variables that could drive the due date, we script it like this:
var reqdate = '';
if(current.variables.requested_by_date){
reqdate = current.variables.requested_by_date.getDisplayValue() + ' 16:00:00';
}
else if(current.variables.business_critical_date){
reqdate = current.variables.business_critical_date.getDisplayValue() + ' 16:00:00';
}
else if(current.variables.requested_completion_date){
reqdate = current.variables.requested_completion_date.getDisplayValue() + ' 16:00:00';
}
var gDate = new GlideDateTime();
gDate.setValue(reqdate);
current.due_date.setValue(gDate);
‎11-03-2017 12:09 PM
Create a Variable "Delivery Time" and update it's value based on need their item by.
var date1 = new Date(g_form.getValue('need their item by'));
var date2 = new Date();
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
var del_date = diffDays +" Days"
g_form.setValue('Delivery_Time',del_date )
now in workflow run script set your due date to 'need their item by' .
current.due_date = current.variables.need their item by;