- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 07:19 AM
Only group members who have an active user record in sys_user table should be added to the group when the transform runs.
Group members should only be added to an active group in the sys_user_group table.
So columns should be mapped as SOEID as user.user_name and group name as group_name.
So for we need onbefore scripting we have created that scripting but it is showing inactive users also.
The script is in the attachment.
Source Field: u_group_name
Target Field Mapping: group.name
Target Table:sys_user_grmember.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 08:45 AM
Hi,
You can try this script:
on Sys_user table first you will check whether user is active or not
var grusr = new GlideRecord("sys_user");
grusr.addActiveQuery();
grusr.addQuery("user_name", source.SOEID ); // i am assuming soeid is source user field
grusr.query();
if(grusr.next()){ //if user is active then go to the sys_user_grmember table add user to that group
var grusrmbr = new GlideRecord("sys_user_grmember");
grusrmbr.addQuery("group.name", u_group_name); //u_group_name is source grup name
grusrmbr.query();
if (grusrmbr.next()) {
target.user = source.SOEID;
} else {
target.user = '';
}
}
Thanks,
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 09:17 AM
Hi
If your issue got resolved please close the thread by Marking ✅ Correct. So that others can benefit.
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar