Reference Qualifiers - Adding Multiple Conditions

andrewdunn
Giga Expert

Hi - looking for some assistance.

I believe this is an easy issue which I just cannot get my text correct

I have my assignment group Reference Specification as:

  • Use reference qualifier: Advanced
  • Reference qual: javascript:new BackfillAssignmentGroup().BackfillAssignmentGroup()

The above means that if an "Assigned To:" person is entered and the ITIL user wants to see what Assignment groups they are a member of they get the correct list.

What I want to do is also have the Assignment Group limited to just those groups that start with "IT"

If I do a simple qualifier I get the code "nameSTARTSWITHIT^EQ"

However I cannot combine them into one string to both work


What I have tried (amongst other options):  

  • javascript:'new BackfillAssignmentGroup().BackfillAssignmentGroup()^'+nameSTARTSWITHIT^EQ()
  • javascript:'new BackfillAssignmentGroup().BackfillAssignmentGroup()^'^nameSTARTSWITHIT^EQ()

Any ideas would be appreciated

cheers

1 ACCEPTED SOLUTION

Sure. Try this:



javascript: var refQual = ''; if (current.assigned_to != '') {var usr = gs.getUser(); usr = usr.getUserByID(current.assigned_to); var grp = usr.getMyGroups().toArray(); refQual = 'sys_idIN' + grp.join()} refQual += '^nameSTARTSWITHit'; refQual;


View solution in original post

20 REPLIES 20

Ok, so if I understand correctly, if person A is member of group ITServices and KPOServices, only ITServices should come up.


In that case, we can, at the Group level, make another field, which will mark it as IT or non-IT.


You can set a Choice field having values IT and Non-IT(Or other values according to your requirement), suppose the field name is u_type.



Now, you can easily filter :- ^u_type=IT


so you want backfill plus the groups that starts with IT even if the assigned to person does not belong to the IT group? If that is the case, see if this helps ..



function BackfillAssignmentGroup(userID)


{


      var groups = [];


      var grp = new GlideRecord('sys_user_grmember');


      grp.addEncodedQuery('user='+userID+'^NQgroup.nameSTARTSWITHIT');


      grp.query();


      while(grp.next()){


              groups.push(grp.group.sys_id.toString());


      }


     


      return 'sys_idIN'+groups.toString();


}


Slava Savitsky
Giga Sage

What if just put the following code into the 'Reference qual' field?



javascript: var refQual = ''; if (current.assigned_to != '') {var usr = gs.getUser(); usr = usr.getUserByID(current.assigned_to); var grp = usr.getMyGroups().toArray(); refQual = 'sys_idIN' + grp.join() + '^nameSTARTSWITHit'} refQual;



If the assignee is not specified, it will return all groups. Otherwise, it will return only the groups that start with 'IT' and contain the assignee. Is this what you are trying to achieve?


Hi Slava , 

 

Can you help me with my issue . 

 

On a story record (rm_story.do) , there is a lookup field called 'Release' , when user clicks on this lookup field , all release's  are visible including those that are Closed or cancelled ,

User don't want to see the Closed or cancelled one's .

I right clicked on that field  -->clicked  ' Configure Dictionary'  to set a  'simple' reference qualifier like

'state'--is not one of -- completed or cancelled . 

But issue is , when i did configure dictionary on that field , there is already a OOB 'Advanced ' reference qualifier shown below

"    javascript:'sys_idIN'+ScrumSecurityManager.getStoryDotRelease(current).join(',')   " 

  • what does this 'Advanced' reference qual do ?
  • if i add simple reference qual ,then  this advanced qual is going away , can we keep both ? How to keep both ?
  • if i remove this advanced qual and add a simple reference qual as i stated above , whats the impact of this advanced qual going away ?

 

Thank you very much for your help in advance . 

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

While an advanced reference qualifier will work, you are now maintaining another script.   A simple reference qualifier should work as it did for me in a quick test (assuming I understand your requirement):


ServiceNow.png



Just add the Sys ID is javascript:getMyGroups() and you should be good.   That is an out of the box function that gets an array of the groups the current user is a member of.