Business rule - Write a global BR for a scoped application

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 11:02 PM
What is the impact of writing a business rule with Application set as Global on a table which is defined in a scoped application? Please cite an example to help understand the reply better.
Regards,
Anish
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 11:20 PM
Did I get it right - If I say the Business rule executes only when the users have the application set to the scoped one?
Let's assume a before update BR exists.
User A has scope set to Global, user B has scope set to <scope_name>.
Both users update the table.
Is the following the output?
User A does not see the business rule executing any actions while updating.
User B does see the actions executed via the BR.
Cheers,
Anish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2022 09:17 AM
Just add this as a condition on the Business Rule, where sys_id_of_application is the sys_id of the application scope that the user must be in for the script to run. This would go in the Condition field above the Script field. The Advanced checkbox needs to be checked to see these fields.
gs.getCurrentApplicationId() == sys_id_of_application;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2022 08:57 AM
Hi,
You need to add condition to your BR
The method is
gs.getCurrentApplicationId()
This returns the 'sys_id' of the current application the user is in.
Use this sys_id to GlideRecord into 'sys_apps' and you'll get the name of the app.
If this condition matches, BR executes else not.
so user logged in and try to do CRUD operation on that table, it checks the scope as per condition and executes BR else not.
Hope this is helpful. If yes then please mark this answer as correct.
Anshu