Run a BR in list view and form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:09 AM
Hello,
I wanted to execute a BR when incidents are displayed in reports and when incidents are opened. I tried all types and conditions but nothing worked.
(function executeRule(current, previous /*null when async*/) {
var openedDate = new GlideDateTime(current.opened_at);
var endDate = new GlideDateTime();
var statusDate = openedDate.getDate();
var currentDate = endDate.getDate();
var diff = GlideDateTime.subtract(openedDate, currentDate);
var finalTime = new GlideDuration(diff);
//var days = diff.getDisplayValue();
current.u_days_open = finalTime;
current.update();
})(current, previous);
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:16 AM
Hi,
Can you please share what you want to achieve? It would be helpful to suggest appropriate solution.
Business rules execute when any database operation is performed like Query table, Update record, delete record etc.
Also display business rule execute when a record is opened from the database and presented to user.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:19 AM
Whenever an incident is displayed in the report or viewed in form a custom field should be updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:17 AM
when incidents are opened.
Use Display Business Rule
And using query business rule , you should only be able to modify the query.
The script that you are using can be done via scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:30 AM
Hi,
Whenever an incident is displayed in the report or viewed in form a custom field should be updated.
The above doesn't seem to be a valid business use-case/requirement
There could be multiple users who can view the incident report or open the record
Then how will you handle that case
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader