SLA set breach date and time based on record producer variable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2024 09:51 AM
We have record producer on portal which create case record with variables under variable editor.
We want to set SLA breach date and time based variable available on record producer called custom date time.
i am trying to achieve using below code but no luck.
How to call variable under relative duration date and time.
(function() {
var startDateMs = calculator.startDateTime.getNumericValue();
var dueDate;
// Work out if "current" is a Task record or Task SLA and then get the "due_date" element from the Task
var tableName = current.getTableName();
if (tableName) {
var baseTableName = GlideDBObjectManager.getAbsoluteBase(tableName);
if (baseTableName == "task")
dueDate = current.variables.u_custom_sla_date;
else if (baseTableName == "task_sla")
dueDate = current.getElement("task.variables.u_custom_sla_date");
}
// if we've got a "due_date" and it's after our SLA's Start time then use it
// otherwise we'll have to default to the same as Start Time plus 1 second (i.e. instant breach of SLA)
if (dueDate && !dueDate.nil() && dueDate.dateNumericValue() > startDateMs)
dueDate = dueDate.getGlideObject();
else {
dueDate = new GlideDateTime(calculator.startDateTime);
dueDate.addDays(10);
}
// if we have a schedule then check if the Due Date is in it and if it isn't
// find the next time we are in the schedule
if (calculator.schedule && !calculator.schedule.isInSchedule(dueDate))
dueDate.add(calculator.schedule.whenNext(dueDate, calculator.timezone));
// set the endDateTime property of the calculator object to dueDate
calculator.endDateTime = dueDate;
calculator.calcScheduleDuration();
})();
please help.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2024 01:14 PM
Hey @Shruti Bhosale,
Is it possible to map the value of the date/time variable to a date/time field on the case record (e.g. due date) via the Record Producer script?
And then, you can use the field for the SLA condition.
Cheers