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.

Field subcategory field depending on multiple categories field sys_choice

Jeff W NZAO B
Mega Guru

Hello,

 

I have an issue, I try to create my script include function to set the subcategory results depending on category value.

I created a simple script include with all the conditions filter from the sys_choice, in the reference qual i put this -> javascript: new EDFcatalogUtils().getSubcategory(current.variables.v_category);

 

Thanks for your help

8 REPLIES 8

Jeff W NZAO B
Mega Guru
getSubcategory: function(subcategory){
		//Filter the subcategory to with the category
		var grINC = new GlideRecord('sys_choice');
		var subcategories = [];
		gs.info("Subcategory et subcategories" + ' '+ subcategories + ' '+ subcategory);
		grINC.addEncodedQuery('element=subcategory^name=incident^language=fr^inactive=false' + subcategory);
		grINC.query();

		while (grINC.next()) {
			// Ajoute le sys_id de chaque enregistrement trouvé dans le tableau listSubcategory
			subcategories.push(grINC.subcategories.toString());
		}

Jeff W NZAO B
Mega Guru

portal form

yes Portal form

Jeff W NZAO B
Mega Guru

yes portal form