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

Ramkumar Rajend
Tera Expert

Hi Andrew,



You can add this condition in the BackfillAssignmentGroup() function as an encoded query



object.addEncodedQuery('group.nameSTARTSWITHIT');



I guessm this will resolve your query.



Ram--


Kalaiarasan Pus
Giga Sage

Reference Qualifer : javascript: BackfillAssignmentGroup(current.assigned_to)



Script Include:


Name : BackfillAssignmentGroup



Script :


function BackfillAssignmentGroup(userID)


{


     


      if(userID == '')


              {


              return;


      }


      var groups = [];


      var grp = new GlideRecord('sys_user_grmember');


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


      grp.query();


      while(grp.next()){


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


      }


     


      return 'sys_idIN'+groups.toString();


}



Note : Returning all groups if the assigned to is blank


Thankyou both for the response - I know what I am going to be playing with over the Christmas period - cheers


Hi - I have been playing around with this and still doesn't work for me.


If I do the reference qualifier:


  • javascript:new BackfillAssignmentGroup().BackfillAssignmentGroup()
  • It correctly shows groups that the assigned to is a member of

If I do the reference qualifier:


  • active=true^nameSTARTSWITHIT
  • It correctly only shows groups starting with IT

However I feel that I should be able to combine these as one Reference Qualifier that will only show groups starting with IT and still retain the BackFill statement



I have tried Encoded Query Strings - ServiceNow Wiki (sections 2.4) and also Reference Qualifiers - ServiceNow Wiki


with no luck.



Am I being naí¯ve in thinking that these could be combined in one piece of code?


Cheers