[Scoped App] Before/After Business Rule not triggering on 'sys_audit_role' global table

Cris P
Tera Guru

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?

1 ACCEPTED SOLUTION

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?

View solution in original post

12 REPLIES 12

Pavankumar_1
Mega Patron

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.

 

find_real_file.png

 

Hope it helps!

Please Mark ✅ Correct if applicable, Thanks!! 

 

Regards

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Hello,

I am currently not trying to update anything on that table, I am just reading data

Community Alums
Not applicable

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..