How the list Collector field dependent on another list collector field in catalog

varshajain
Tera Expert

I have one list collector field country which takes reference from core company table
and other list collector field Company Code which takes reference from custom table and in this custom table one field country which takes reference from same core company table.

Now I want whatever multiple value I selected in country, its dependent code should only visible in company code field. 

I tried with client script and reference qualifier but it doesn't work.

3 ACCEPTED SOLUTIONS

@varshajain 

u_country_reports -> reference to core_country table?

Share dictionary config screenshot for this

variable "for_which_countries_do_you_want_the_" refers to core_country table?

share variable config screenshot for this

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

View solution in original post

@varshajain 

Thank you for marking my response as helpful.

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

View solution in original post

@Ankur Bawiskar 
Thank you so much for your response. It works from your method by only reference qualifier and script include is not required.

View solution in original post

20 REPLIES 20

Utpal Dutta
Tera Guru

Hi there,

I think this community post is similar to your query. Can you give it a try and let me know if it is working for you or not?

 

Thanks

Found one more community post which talks about taking value from list collector. Please refer it here.

 

If my answer helps then please mark it Helpful & Accept the solution.

 

Thanks

Hi @Utpal Dutta , Thank you for the response

 

Yes, It is quiet similar but type of field for both is list collector and in that post reference is mentioned. So in list collector multiple values can be selected so dependent also works accordingly.
But the proposed solution in that post doesn't work for me

Hi @varshajain,

I implemented this in my PDI. Let me guide you below:

 

Create a script include that will glide record your custom table to fetch all records which are refereing to company table like below: (Make sure its a server script inculde not client)

var GetCompanyServer = Class.create();
GetCompanyServer.prototype = {
    initialize: function() {
    },

	getCompanyCode: function(company){
		var companyName = '';
		var grComCode = new GlideRecord('u_company_with_codes'); //Replace this table name with you custom table name.
		grComCode.addQuery('u_company_code', 'IN', company); //Replace 'u_comany_code' with company code field name in your custom table.
		grComCode.query();

		while(grComCode.next()){
			gs.log('Company names are: ' + grComCode.getValue('u_company_name'));
			companyName += ','+grComCode.getUniqueValue();
		}
		gs.log('Company names returning: ' + companyName);
		return 'sys_idIN'+companyName;
	},

    type: 'GetCompanyServer'
};

 

Then you need to modify the reference qualifier of your company code variable like below:

javascript:new global.GetCompanyServer().getCompanyCode(current.variables.company);

Replace "current.variables.company" with your company variable name.

 

Once this is done then test your catalog item. When you will change the company variable on your catalog item, Your company code variable will only have those company code which belong to that particular company you selected.

 

Screenshot below:

UtpalDutta_0-1752830658533.png

 

Custom table records:

UtpalDutta_1-1752830682107.png

 

Please Accept my solution if it helps

 

Thanks