Auto populate Assignment group based on Assigned To name

praveen47
Tera Contributor

Hello, 

 

I have a requirement, 

 

In Agent Workspace Interaction form, As per my Instance Agent workspace is only Accessible only for "service Desk", "Local Desktop", "helpdesk" group members, and Assined_to field is populated with loggedin User name. My requirement here If the Assigned_to is part of all three groups then Assignment group should be "Local Desktop". if the Assigned_to User is only part of "ServiceDesk" or "Helpdesk" then Assignment group should be - service desk. I need to check the user included in these three group then prioratize and assigned to "Local Desktop". 

 

can any one help on this requirement how the prioratize Assignment group based on Assigned_to.

 

Thanks,

Praveen.

2 REPLIES 2

Manmohan K
Tera Sage

Hi @praveen47 

 

You can use logic like below to he prioritize Assignment group based on Assigned to user.

(Make changes as required with names of group)

  // Get the current user's groups
  var userGroups = gs.getUser().getMyGroups();

  // Check if the user is part of all three groups
  var isMemberOfAllGroups = (
    userGroups.indexOf('service Desk') !== -1 &&
    userGroups.indexOf('Local Desktop') !== -1 &&
    userGroups.indexOf('helpdesk') !== -1
  );

  // Set the Assignment Group based on the user's group membership
  if (isMemberOfAllGroups) {
    current.assignment_group = 'Local Desktop';
  } else if (
    userGroups.indexOf('service Desk') !== -1 ||
    userGroups.indexOf('helpdesk') !== -1
  ) {
    current.assignment_group = 'service desk';
  }

 

 

@Manmohan K , 

 

I need to write this script using Script include and catalog client script. Can you help on this.

 

Thanks,

Praveen.