- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2019 09:02 AM
Hi,
I have created an after business rule on the issue table with the following conditions:
Materiality rating (on associated control) = high
Status (on associated control) = non compliant
My code:
(function executeRule(current, previous /*null when async*/) {
var date = new GlideDateTime();
date = current.start_date;
date.addDays(25);
current.end_date=date;
}
)(current, previous);
All I'm wanting to do is add 25 days to the planned end date field on the issue. Can anybody point out what I'm doing wrong?
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2019 09:29 AM
Ahhh Scoped app of course, addDays will not work on that.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2019 09:19 AM
If you're unsure what you're getting or if this script is even working...you really need to use log statements, etc. to troubleshoot. Since now you're wondering if your conditions are the issue. Please remove conditions and test without and add log statements to see how things are going.
If the start_date and end_date fields are Date only fields...not DateTime...you're going to run in to possible problems.
You can try:
var date = new GlideDateTime();
date.setValue(current.start_date);
date.addDays(25);
current.end_date=date;
otherwise if it's Date only:
var date = new GlideDate();
date.setValue(current.start_date);
date.addDays(25);
current.end_date=date;
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2019 09:26 AM
Thank you all. Turns out addDays was the issue and I had to use addDaysUTC for sn_compliance_control.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2019 09:29 AM
Ahhh Scoped app of course, addDays will not work on that.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2019 11:10 AM
Glad you got it resolved. Technically, you answered your own question, which should be marked as Correct so that people don't see a different reply marked as Correct thinking that's what resolved it, but since you didn't state that it was a scoped app in your original post, perhaps they won't be confused... Just throwing that out there.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!