- 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:10 AM
Hi there,
Below code is working for me (just tested this on a after BR on change request):
var date = new GlideDateTime(current.start_date);
date.addDays(25);
current.end_date = date;
current.update();
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:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 09:17 AM
Hello Bracken,
Try removing conditions and test it. Also add logs to check BR is running or not.
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 09:26 AM
I can't tell where these conditions are coming from / if these are correct. For example, maybe the Control is empty? Though you could start the script with a log statement. For example:
gs.info('BR Test');
Then check if this is written in the system log. If not, did not trigger.
There are more debugging options, like the script debugger, though I don't know how experianced you are.
If my answer helped you in any way, please then mark it as helpful.
Have you also checked the other When to run fields? Like is this on Update? Or on insert? Etc..
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field