- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2014 04:52 AM
Hey all,
How would I script a prompt that stops a change with an impact of high being logged less then 7 days ahead of the date the change is being raised. I have tried amending the script that stops changes having an end date before planned date but have not got it right.
Any hep would be appreciated.
Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2014 09:29 AM
Something like this should give you a good jumpstart:
When:Before Update
Condition: (current.start_date.changes() || current.impact.changes()) && current.impact == 1
Script:
if(current.start_date <= gs.daysAgo(-7)) {
current.setAbortAction(true);
gs.addInfoMessage("The planned start date must be more than 7 calendar days in the future.");
}
If you're wanting it to be 7 business days, it'll be more complicated, with the Script being more like:
if(calcLeadTime(current.start_date, gs.now()) < 7*8*60*60) {
current.setAbortAction(true);
gs.addInfoMessage("The planned start date must be more than 7 calendar days in the future.");
}
function calcLeadTime(start,begin){
var dc = new DurationCalculator();
dc.setSchedule('SYS_ID_OF_8_TO_5_BUSINESS_DAYS_SCHEDULE',"");
return(dc.calcScheduleDuration(begin,start,true));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2014 07:00 AM
I'm not quite sure what the blank error message was, unless the blank error was the one that normally says "Invalid update" (which shows up whenever you use "current.setAbortAction(true)".
Based on your other reply saying you figured it out, we'll just table this.
Glad you got it working!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2014 01:18 AM
So, I have De-activated the first rule I set up and created it again and it works fine. Both had been copied and pasted but ill compare side by side and see if I can spot the problem. if I find anything ill post in this thread for future reference. Thanks for your help. Most appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2014 06:58 AM
Wow! It's always nice when something like that happens to fix the issue. Let me know if you can figure out what happened, sounds like a very interesting case study.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2014 07:01 AM
Will do. Knowing me its something really obvious I have overlooked. When I
find it ill let you know.
On 23 October 2014 14:59, Garrett Griffin-Morales <