automate calculation of problem end date for RC Analysis Tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 09:05 AM
Hi All,
1. we have a requirement like auto populated problem due date when incident is p1, problem due date should be+7working days.(Monday to Friday)
2. if incident is p2 problem due date should be +12 working days(Monday to Friday).
3. problem due date should auto populated when problem state is Root cause analysis.
4. when we create problem task from the same problem table, also populated problem_task due date value.
Please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 09:34 AM - edited 11-14-2023 11:29 AM
You can use GlideSchedule and pick a schedule from your organization so that you will get working days and now write a business rule and add days to it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 10:00 AM
Hi @harshav ,
I'm using below business rule but it's not working
table: problem
when : before insert, update
var date = new GlideRecord('incident');
date.addQuery('priority', 1);
date.query();
while(date.next()){
var days = 7;
var created = new GlideDateTime(current.sys_created_on);
var duration = new GlideDuration(1000*60*60*8*days);
var schdule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae');
var duedate = schdule.add(created,duration);
current.due_date = duedate;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 11:45 AM - edited 11-14-2023 11:51 AM
You are running this on your problem table and trying to update the problem due-date. I don't understand why are you querying the incident table with out passing in any value in the query. please correct that one.
Also in your schedule check the start time and endtime how it is considered as a day. for example in this case the system will show the exact date if the start time and end time diff is 8 hours. (ie; 8-5 Weekdays schedule). in case your schedule is 24 hours update this line var duration = new GlideDuration(1000*60*60*8*days); to var duration = new GlideDuration(1000*60*60*24*days);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 05:56 PM