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

Community Alums
Not applicable

Hi @Jeff W NZAO B 

Could you please provide more information on this requirement. Is there service portal form? Why you wrote script include when you have option to use dependency field ref this.
Please provide snapshot of script include

Please Mark  Correct & 👍 Helpful, if applicable.

Regards,
Akshay


I'm creating the function in a script include, to filter my subcatery list by adding the query filter on incident table, so at the end i want on my portal form the subcategory field filtered on incident values only

Thanks

here is the script include, and within the reference qual of the variable field, i just added the function name
 
myFunction: function(subcategory){
//Filter the subcategory to with the category
var grIC = new GlideRecord('sys_choice');
var subcategories = [];
gs.info("Subcategory et subcategories" + ' '+ subcategories + ' '+ subcategory);
grIC.addEncodedQuery('element=subcategory^name=incident^language=fr^inactive=false' + subcategory);
grIC.query();
 
while (grIC.next()) {
subcategories.push(grIC.subcategories.toString());
}
gs.info("Subcategory IC" +  subcategories.push(gr.getDisplayValue('sys_id') + 'JEFF 0'));
return subcategories;​

 

 

I created my script include where i put my function for the subcategory, and i added the function name in the reference qual of my varaible fiedl from the portal form.

The subject is portal form 

 

maFunction: function(subcategory){
		//Filter the subcategory to with the category
		var gr = new GlideRecord('sys_choice');
		var subcategories = [];
		gs.info("Subcategory et subcategories" + ' '+ subcategories + ' '+ subcategory);
		gr.addEncodedQuery('element=subcategory^name=incident^language=fr^inactive=false' + subcategory);
		gr.query();

		while (gr.next()) {
			subcategories.push(gr.subcategories.toString());
		}