Filtering Assignment group based on Logged user

manish123
Giga Guru

Hi All,

In Incident page, if logged in user belong to Service Desk group then they could not able to see Admin group in "Assignment group" reference field. However, for others it will be accessible and visible. As per my knowledge, i think this could be achievable through defining the script include and referred it under advance qualifier.I have added log message too. In Admin group level, i have defined its type as Restricted and passing its sys_id in Query. However, It's hiding for all user and i couldn't able to see any message which should have printed on log file. Therefore, i think it's not executed at all. from where & how do i verify the same?

function backfillAssignmentgroup()

{

  try

  {

  gs.log(" hello");

  var grps='';

  var usr = gs.getUser().isMemberOf('Service Desk');

  if (usr == true)

  {

  var grp = new GlideRecord('sys_user_group');

  grp.addQuery('active',true);

  grp.addQuery('u_isparent',false);

  grp.addQuery('type','DOES NOT CONTAIN','123454a2370c82007b1e4a7a43990eec'); //Admin

  grp.query();

  while(grp.next())

  {

  grps+=(','+grp.sys_id);

  gs.log(' Name of Assignment group'+ grps);

  }

  return 'sys_idIN'+grps;

  }

  else

  {

  return;

  }

}

catch(err)

{

  gs.log('BackfillAssignment Issue' + err.message);

}

}

Any help would be much appreciated.

13 REPLIES 13

I want to know if this worked haha

Ian Kirby1
Giga Expert

Could you not use a Before Query business rule on sys_user_group to define a default reference qualifier for the Service Desk group. This would restrict the data returned in the query for that particular group in all cases where the Assignment Group is returned.



e.g.


if (gs.getUser().isMemberOf('Service Desk')) {


  current.addQuery('active',true);


  current.addQuery('u_isparent',false);


  current.addQuery('type','DOES NOT CONTAIN','123454a2370c82007b1e4a7a43990eec'); //Admin


}



A reference qualifier on the reference field will also work but this will add the call time of the reference qualifier to the screen refresh time.


Thanks Ian, However, you are defining it on sys_user_group table does it not affect Incident, problem, CR all. Because I would like to implement this only for Incident form.


Yes, it would affect the query wherever the Service Desk group member is viewing it. If this is not a global restriction for your Service Desk, you want to implement it using the reference qualifier route - as you are doing.