automate calculation of problem end date for RC Analysis Tasks

pvv1045330
Tera Contributor

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.

 

 

 

 

6 REPLIES 6

harshav
Tera Guru

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.

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;
}

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); 

Hi @harshav ,

 

here i want populated problem due date based on incident priority is p1