Creating Workflow to add and remove users from assignment groups

aismail
Kilo Contributor

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

1 ACCEPTED SOLUTION

randrews
Tera Guru

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();


}


View solution in original post

29 REPLIES 29

Yes, ours is a little more complicated because we added a layer in above Groups, but ultimately, we use a script that makes all the changes we want.


pilar
Kilo Contributor

Mike,



Your script sounds interesting could you provide a copy pls.



Thank much



Pilar


Thank you Mike for your insight. I am also very interested to know how you designed your scripts in order to accomplish a slightly more complex approach. Would you happen to have an algorithm or high level code that illustrates the steps?


askl
Kilo Contributor

Hi Mike,



Can you share your run script for generating request and closing the task once the approval got approved/rejected.



My requirement is if a user wants access for three groups then three tasks with one service request has to be generated. unless all tasks gets closed the request should not be closed.



And another flow for removing users from group should take place if the user selects option as remove group in option



Thank you


i am unclear on what you mean by the workflow to create tasks and requests it is a standard catalog item ...


the approval is sent to the group manager from the variable.. <we limit people to one group each> to make this work for multiple groups you would just make the group to add a list collector and get the manager of each group via workflow script in the approval... to add/remove them from a group simply insert/delete a row on the sys_user_grmember table...