filtering a list dependent on a field value

scottjus82
Kilo Guru

Hey all.

 

I have a list field on my change form which is a reference to the user table. someone raising a change can use this to populate who receives emails regarding a change, so if we are implementing a change that impacts multiple clients we can select the relevant people from those clients to receive the workflow emails. If I select that the change is internal I only want internal users to be available in that list (user.company field) How would I do this? i have a feeling it will be a reference qualifier but I am not sure what it would look like.

 

Any thoughts?

 

Thanks

6 REPLIES 6

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I think you should be able to use an advanced reference qualifier.



You could probably do something like this in your script include where current.impact is the field you're dependent on and campnyid is the sys_id of your internal company. Haven't tested this, but it should get you started.



function impactQualifier() {


  var refQual = '';


  if (current.impact == 'internal') {


          refQual = 'company=companyid';


  }


  return refQual;


}


poyntzj
Kilo Sage

I agree with Brad



You can make it as complicated or as easy as you like


Attached is a ScriptInclude I use. It has 3 functions.   A simple one to call another function, one that will get a list of Assignment groups based on Form and the groups you as a user below to, and then finally the complicated on that determines what users are actually visible in the Assigned to field (based on if you are manager, co manager, in the office, an ebonding group!)



The Assignment Group reference qualifier is as follows


javascript:new GroupMLongReferenceQualifier().AssignmentGroup()



The Assigned To reference qualifier is as follows. It take the above group and then does the hard work


javascript:new GroupMLongReferenceQualifier().AssignedTo(current.assignment_group)




we have other Reference qualifiers for things like restricting the CI list which is basically composing a very long reference qualifier line.


Hey guys,



thanks for the response.



Julian, you mentioned about having attached your script include but I cant see an attachement.



Brad, I have tried using yours however I have setup script includes and dynamic filter options but they do not appear in the list to select when adding to my ref qualifier. What am I doing wrong? they have saved and appear in the list if I go through the application menus but I cant apply to dynamic ref qualifier.....


I see an attachment on my post


sys_script.include........(1).xml