- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2014 08:02 AM
I want to update the "notification" field on the sys_user record when the user is added to a specific group.
I am trying with a Business Rule but haven't been able to make it work. Is a Business Rule the best way or should I use a Client Script?
This is the rule I have created on the Group [sys_user_group] :
updateNotification();
function updateNotification() {
var user = current.user.getRefRecord();
if (!user.isValid())
return;
var group = new GlideRecord("sys_user_group");
if (current.group =='Notification Disabled') {
user.notification = 1;
}
user.update();
}
Thanks for any insight!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2014 03:00 PM
Hello,
There are a few ways to accomplish this task. I think the simplest one would be to use a business rule. Here is some sample code that should accomplish what you are trying to do. You will of course have to replace the sys_id I have hard defined here with the sys_id of the group you would like this to apply to. Let me know how this works out.
updateNotification(current.user);
function updateNotification(userSysID) {
if(current.group == '8a5055c9c61122780043563ef53438e3'){
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id','=',userSysID);
gr.query();
while (gr.next()) {
gr.notification = 2;
gr.update();
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2014 03:00 PM
Hello,
There are a few ways to accomplish this task. I think the simplest one would be to use a business rule. Here is some sample code that should accomplish what you are trying to do. You will of course have to replace the sys_id I have hard defined here with the sys_id of the group you would like this to apply to. Let me know how this works out.
updateNotification(current.user);
function updateNotification(userSysID) {
if(current.group == '8a5055c9c61122780043563ef53438e3'){
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id','=',userSysID);
gr.query();
while (gr.next()) {
gr.notification = 2;
gr.update();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2014 06:07 AM
This works perfect, Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2014 12:22 PM
The "correct answer" worked for my initial question. However, I now realize I need to update the "notification" field on the SN sys_user record when it is updated from LDAP because the user was added to the group in the AD. Would it require a transform script that runs when the LDAP upload completes?
Thanks,
Lorna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2014 08:40 AM
Final working solution: I made the BR script "client callable", and added the function to a transform script in my Group Import Transform Map, to run "onComplete".
Now I just have to figure out the best way to update notification if a user is removed from the group...in AD.
Lorna