Update the location from Portal then add that user to group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 01:18 AM - edited 08-31-2023 08:42 AM
Requirements : If End User change the location from the portal (under user profile) then add that user to Specific group.
The below code is working fine, when we change the location field on user (Sys_user) table.
But we need to change the location from portal (or) from preferences the below code is not working.
Please help me on this requirement.
// Before BR condition is location changes to

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 06:45 AM
Hi @Suresh_32,
If you are changing it from somewhere else as the user record, your current object is not going to be the user record.
Assuming that the user is changing it themselves, you could use below script.
Otherwise, you will need to get the information of the user somewhere first.
// Before BR condition is location changes to
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var myGroup = 'bca6ab3f87a0b910d02fa6c83cbb354d'; // Group SysID
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', myGroup);
gr.addQuery('user', gs.getUserID());
gr.query();
if (!gr.next()) {
gr.initialize();
gr.group = myGroup;
gr.user = gs.getUserID();
gr.insert();
}
})(current, previous);
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 08:39 AM
Hi Peter,
Thank you for your reply.
BR is not trigged for the above code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 08:24 AM
Hi, do you want to trigger an business rule if the language changes?
You need to make an Business Rule on the sys_user_preference table selecting the preference user.language