If change the Language under User preferences then automatically add that user to specific group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 08:00 PM
Requirements : If User change the language under user preferences then automatically add that user to specific group. PFA.
Please help me on the below code .
// Before and update BR (on User table), condition is language changes to
preference.addQuery('user', gs.getUserID());
preference.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 08:29 PM
Hi @Sravani47,
You need to changed your BR to After update on User [sys_user] table.
Condition:
Language CHANGES
Updated scripts:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var myGroup = 'bca6ab3f87a0b910d02fa6c83cbb354d'; // Group SysID
// Convert sys_id to System property as
// var myGroup = gs.getProperty('add.proprty.name.here');
var preference = new GlideRecord('sys_user_preference');
preference.addQuery('user', gs.getUserID());
preference.addQuery('name', 'user.language');
preference.query();
if (!preference.next()) {
var newRecord = new GlideRecord('sys_user_grmember');
newRecord.initialize();
newRecord.group = myGroup;
newRecord.user = gs.getUserID();
newRecord.insert();
}
})(current, previous);
System Properties & it's Usage
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 08:46 PM
I have tried with the above code but BR is not triggered .