Condition Builder Caller is Member of Group

Katie A
Mega Guru

Hello, I am writing a report and I would like to use the condition builder to check if the Caller is a member of a certain group.

Table: Incident

Condition: Caller - Is Member Of - Groupname

I know that I probably need to build javascript class to call within the condition. How can I build this?

1 ACCEPTED SOLUTION

You will need to create a new client callable script include



Script include:


Name:GetCallerIncidents


clitn callable: true


var GetCallerIncidents = Class.create();


GetCallerIncidents.prototype = Object.extendsObject(AbstractAjaxProcessor, {


  callerGroup: function(group){


  var mem=[];


  var id=[];


  var grmem= new GlideRecord('sys_user_grmember');


  grmem.addQuery('group.name',group);


  grmem.query();


  while(grmem.next()){


  mem.push(grmem.getValue('user'));


  }


  var gr= new GlideRecord("incident");


  gr.addQuery('caller_id','IN',mem.join());


  gr.addActiveQuery();


  gr.query();


  while(gr.next()){


  id.push(gr.getValue('sys_id'));


  }


  return id.join();


  },


  type: 'GetCallerIncidents'


});




Now in your report use this



sys_id IS ONE OF   javascript: new GetCallerIncidents().callerGroup('your exact group name goes here');


View solution in original post

6 REPLIES 6

dvp
Mega Sage
Mega Sage

On which table are you trying to build this?


Incident table


You will need to create a new client callable script include



Script include:


Name:GetCallerIncidents


clitn callable: true


var GetCallerIncidents = Class.create();


GetCallerIncidents.prototype = Object.extendsObject(AbstractAjaxProcessor, {


  callerGroup: function(group){


  var mem=[];


  var id=[];


  var grmem= new GlideRecord('sys_user_grmember');


  grmem.addQuery('group.name',group);


  grmem.query();


  while(grmem.next()){


  mem.push(grmem.getValue('user'));


  }


  var gr= new GlideRecord("incident");


  gr.addQuery('caller_id','IN',mem.join());


  gr.addActiveQuery();


  gr.query();


  while(gr.next()){


  id.push(gr.getValue('sys_id'));


  }


  return id.join();


  },


  type: 'GetCallerIncidents'


});




Now in your report use this



sys_id IS ONE OF   javascript: new GetCallerIncidents().callerGroup('your exact group name goes here');


hi abhinay,


I tried the code you have. What do i need to change - i put in the exact group name and it's sysid both.. does not work...


Also is this correct -


sys_id IS ONE OF   javascript: new GetCallerIncidents().callerGroup('your exact group name goes here');



I am using this as a script include but adding this code line above to the field style....where i say that if the user is a member of a group show an image...