- 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:03 AM
Hi,
Since you are using gr.update() you need Write permissions on cross scope. Did you try creating a cross scope privilege for Write operation on custom table?
Regards,
Vamsi S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 04:06 AM
Hi Vamsi,
The gr is an instance of my scoped table 'x_arl_licence', that is the record I am updating, which is in the same scope as my BR, don't believe I will need a cross-scope privilege if I am updating a table in the same scope?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 04:10 AM
Right I missed that in your description. Did you try checking logs to see if there was an error/warning that stops triggering the BR script?
I know its sounds odd but can you try BR in global scope and then create a cross scope for write permissions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 04:16 AM
I have tried just a simple BR on 'sys_audit_role', in global app scope:
(function executeRule(current, previous /*null when async*/) {
gs.info('CRIS Count Role ran'); // still does not run
})(current, previous);
- App scope: Global
- No BR conditions
- Trigger on insert/update
- Active
Perhaps that table cannot have BR running on it? I also tried doing it via Flow, but you cannot even select the table to trigger from!