- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2015 06:16 PM
Hello All,
I am fairly new to ServiceNow and continuously learning new skills and techniques everyday. I have just begun working with Workflows and had a quick question. I am looking to build a slight automation process for users, and was wondering if anyone has experienced a similar build. You insight is much appreciated.
How i am thinking it should work:
1. Catalog item is created where users can request if they want to be removed or added to a group.
2. If they are requesting to be removed, it just automatically removes them (no approval)
3. If they are requesting to be added to a group, an approval is sent out to group manager
4. If group manager accepts, user is added to group and notification is sent out. If rejected then a notification is sent and request is closed.
Is there a better process/design? Any Technic or skills that would help? How would one automate the addition and removal of users? What would be a good place to start in regards to best practice and creating the workflow.
I have tried looking for online resources but couldn't find anything specific to assignment groups. If anyone knows of any resources available, that would be great!
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 07:53 AM
i do it also... just a script to add a row to the table.. like below the flush messages keeps the person who approves the record from seeing any add info messages triggered by the script... the current. comments updates the requested item with the note.
this is in a run script block after the mark as approved item.
addtogroup();
function addtogroup(){
var newgrpmember = new GlideRecord('sys_user_grmember');
newgrpmember.user = current.variable_pool.requested_for;
newgrpmember.group = current.variable_pool.v_member_group_new;
newgrpmember.update();
gs.flushMessages();
current.comments += '\n' + "Added to group " + newgrpmember.group.getDisplayValue();
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 04:17 PM
Hello Raymond,
I love finding useful things like this!
In our case we have to allow users to have multiple group memberships.
That said, how do we alter the code you have graciously shared to "remove" a user from a group?
Thank you in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 07:24 AM
Sure it is basically just looking for the row on the table that added them to the group and deleting the record...
if you want to only remove them from ONE group you would need to add to the query to specify the group <I believe the field is group>
this script runs from a workflow so the current.comments updates the items comments with a note that they were removed from the group and the group name... you cn remove/comment it out if not running this from an Item workflow.
removefromgroup();
function removefromgroup(){
var oldgroup= new GlideRecord('sys_user_grmember');
oldgroup.addQuery('user',current.variable_pool.requested_for);
oldgroup.query();
while (oldgroup.next()){
current.comments += "Removed from group " + oldgroup.group.getDisplayValue();
oldgroup.deleteRecord();
gs.flushMessages();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 08:41 AM
Hi I am new to servicenow and these concepts. Having similar requirement, have two approvals and user has to be added in group. Can you share your workflow and script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 06:47 AM
By using the above code a New Group Member record in sys_group_member table is added instead of adding the requested for user in the group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 06:59 AM
when you add a member to a group all it does is create a new record on the related table sys_user_grmember so yes creating a record on the table is all you need to do.