- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 03:58 AM
Hello everyone,
I have a simple before BR on the 'sys_audit_role' table. The BR is in my scoped app.
I have removed all conditions from the BR and set it to trigger on Insert or Update.
When I remove/add someone's role, the sys_audit_role table inserts a record to show the activity; My issue is that, once this record is inserted into this table, my BR does not trigger. Here is my BR:
(function executeRule(current, previous /*null when async*/) {
gs.info('CRIS Count Role ran'); // This never shows in logs, BR does not run
var licPurchased;
var licAllocated;
var licRemaining;
var operation = current.getValue('operation');
var gr = new GlideRecord('x_arl_licence');
gr.addQuery('company', current.user.company);
gr.query();
if(gr.next()){
licPurchased = gr.licences_purchased; // Check how many they purchased
licAllocated = gr.licences_allocated; // Check how many they have used
if(operation === 'Added'){
licAllocated += 1; // Update allocated licences, add one
}
if(operation === 'Removed'){
licAllocated -= 1; // Update allocated licences, subtract one
}
gr.licences_allocated = licAllocated; // Update allocated licences with new count
gr.update();
}
})(current, previous);
The above gs.info does not show in the logs, so the BR is not running.
The BR is:
- Active
- Has no trigger conditions other than Insert/Update on the table
- My app has a cross-scope privilege recod for the table, for operation 'Read', status 'Allowed'
- The table I am trying to trigger the BR on is 'Accessible from all scopes' and 'Can read' is true
- Ideally, this will be an 'After' business rule, but I have also tried 'Before' BR with same issue
Any ideas why I cannot get this to trigger?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 04:40 AM
Yeah I have created the property and tested the records getting created now. But the BR is not getting triggered so assuming OOTB code might using .setWorkflow(false).
For your usecase, do you see any challenges to create BR on sys_user_has_role table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 04:21 AM
Hi,
Yes you can not update. Please check on table Application Access tab enable Can Update field as shown below. Then you can update the data on this table.
Hope it helps!
Please Mark ✅ Correct if applicable, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 04:32 AM
Hello,
I am currently not trying to update anything on that table, I am just reading data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2024 01:21 PM
Hello Cris, were you able to find the fix? I am also trying to run the Business rules for sys_audit_role table but no luck..