Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

data restrict in list type of variable

dixitreddy
Tera Contributor

In a catalog form i have two variables one is check box other is list collector my requirement is if i select the check box it should populate only few records in listcollector varaible(need to restrict other data) if unchecked it should populate except few

4 REPLIES 4

ayan_murshad
Tera Guru

Hello @dixitreddy,
Add an Advanced Reference Qualifier to the List Collector.

Let me know if you need more details.


Regards,

Ayan Murshad 

Ankur Bawiskar
Tera Patron
Tera Patron

@dixitreddy 

you can use advanced ref qualifier on list collector and use this sample script

Note: ensure you give correct variable name and sysIds for the records you want to show

javascript: var query; if(current.variables.checkBoxVariableName == true) query = 'sys_idINsysId1,sysId2,sysId3'; else query = 'sys_idNOT INsysId1,sysId2,sysId3'; query;

Also ensure in variable attributes of list collector add this

ref_qual_elements=checkBoxVariableName

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar  i have tried this javascript: var query; if(current.variables.amer3_jv_les == true) query = 'u_nameINAMER_US_N0498,AMER_US_N0490,AMER_US_N0508,AMER_US_N0511,AMER_US_N0514,AMER_US_N0502,AMER_US_N0499^u_active=true'; else query = ''; query;

in attribute-- ref_qual_elements=amer3_jv_les

but it is not working

Dino D
Tera Contributor

I assume you're data in the list collector is pulling from a table.  Have you attempted a reference qualifier based on the true/false from your checkbox?

 

I believe you can us a catalog client script controls the reference qualifier for your list collector's data. 

 

I found another suggestion for an 'if' statement inside the reference qualifier

https://www.servicenow.com/community/developer-forum/how-to-use-if-else-statement-in-reference-quali...

 

 

I have up 

 

javascript:if(current.variables.chexkbox_value == 'true')'active=true'; else'active=false';

 Hopefully this helps