Need to populate time left filed incident form which is value of business left time from task_sla
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 06:23 AM
Hi
I have requirement
We created a custom field time left form duration type, and now I want to populate this field with the business time left value from the task_sla table.
could you please any one suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 07:05 AM
Hi @Brahmi Pandla ,
I trust you are doing great.
Here's an example of how you can accomplish it:
- Create a new business rule or script include to perform the necessary calculations and updates.
- Retrieve the relevant record from the task_sla table based on the associated task.
- Calculate the business time left by subtracting the current time from the SLA's end time, taking into account any business hours or holidays.
- Update the custom field "Time Left" on the task record with the calculated value.
// Get the task_sla record for the associated task
var slaGR = new GlideRecord('task_sla');
slaGR.addQuery('task', current.task); // Replace 'current.task' with the appropriate field if needed
slaGR.query();
if (slaGR.next()) {
// Calculate the business time left
var endTime = new GlideDateTime(slaGR.getValue('end_time'));
var currentTime = new GlideDateTime();
var businessTimeLeft = gs.dateDiff(currentTime, endTime, true);
// Update the custom field "Time Left" on the task record
current.time_left = businessTimeLeft;
current.update();
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 07:16 AM
Hi Amit,
Thanks for response , why we need calculate the business time left here, already businesstimeleft field value is avaiable in task_sla table.
i want same value populate to time_left field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 07:44 AM
Hi Amit,
It's not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 03:28 AM
Hi Amit,
Could you please help on this