- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 07:59 AM
I have created a Catalog item for Creating Agile groups
The requirement is to create an Agile group and add members to it and also assign couple of roles once the group is created through the Catalog item. As of now I am able to create a group and but I am only able to assign one role (scrum_user).
The requirement is to assign more than 1 role
I need to add additional roles Ex., scrum_story_creator, scrum_user, project_user, rm_task_admin, timeline_user
Please advise.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 09:46 AM
Hello
try replacing your script with below please
always use .toString() while pushing the sys_ids .
i have used .toString() while pushing role sys_ids
var gr = new GlideRecord('sys_user_group');
gr.initialize();
gr.name = current.name = current.variables.client_name.getDisplayValue() + ' ' + current.variables.project_name.getDisplayValue() + ' Agile Group'; // <<Client Name>> <<Project Name>> Agile Group
gr.type = '1bff3b1493030200ea933007f67ffb6d'; //Type = Agile Team
gr.manager = current.variables.em_name; // Manager Name
gr.managed_domain = true; //Domain
gr.sys_domain = current.variables.client_name; // Domain Name
var grpID = gr.insert(); // Group Created
var grMember = new GlideRecord('sys_user_grmember');
grMember.initialize();
grMember.user = current.variables.group_members;
grMember.group = grpID;
grMember.insert(); // Group member added
var roles = [];
var role = new GlideRecord('sys_user_role');
role.addEncodedQuery('nameINscrum_story_creator,scrum_user,project_user,rm_task_admin,timeline_user');
role.query();
while(role.next()){
roles.push(role.sys_id.toString());
}
var roleID = roles.split(',');
for (var i = 0; i < roleID.length; i++) {
var grRole = new GlideRecord('sys_group_has_role');
grRole.initialize();
grRole.group = grpID;
grRole.role = roleID[i]; // Scrum_story_creator, scrum_user, project_user, rm_task_admin, timeline_user
grRole.setWorkflow(false);
grRole.insert(); //Roles inserted to group
}
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 12:12 PM
Thanks Mohith, The script once I made the recommended changes.