Populate field value based on other field's value

A_maity002
Tera Contributor

Hello,
How can I populate one field's value based on other field's value using 'sys_choice' table dependent field option in MyServicePortal front end ?

I don't want to use script. Just want to populate using dependent field option in sys_choice table. But this is working in backend not in front end. I want that in front end/ServicePortal in catalog_form.

Regards,
Atanu Maity

1 ACCEPTED SOLUTION

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @A_maity002 ,

 

Please refer this community article, this article all the answers for queries. please check let me know if you still have some questions

Creating Dependent Variables in Service Catalog? Here are two ways how it can be done. 

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh

View solution in original post

3 REPLIES 3

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @A_maity002 ,

 

Please refer this community article, this article all the answers for queries. please check let me know if you still have some questions

Creating Dependent Variables in Service Catalog? Here are two ways how it can be done. 

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh

Hello @Siddhesh Gawade ,
Thanks for providing the reference article.

Kind regards,
Atanu Maity

Manikmodi16
Tera Guru

Hi,

Unfortunately, catalog variables do not have a dependency like a field we have on the forms.

Manikmodi16_1-1706514316341.png

 

The dependent variables can be created using a Client Script.

On change Client Script: Onchange of Category field write following script

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '')
	{
		g_form.clearOptions('subcategory');
		g_form.addOption('subcategory', '', '-- None --');
		return;
	}
	if(newValue =='Category 1')
		{
		g_form.clearOptions('subcategory');
		g_form.addOption('subcategory', '', '-- None --');
		g_form.addOption('subcategory','Subcategory11','Subcategory11');
		g_form.addOption('subcategory','Subcategory12','Subcategory12');
		g_form.addOption('subcategory','Subcategory13','Subcategory13');
	}
	else if(newValue =='Category 2')
	{
		g_form.clearOptions('subcategory');
		//g_form.addOption('subcategory', '', '-- None --');
		g_form.addOption('subcategory','Subcategory21','Subcategory21');
		g_form.addOption('subcategory','Subcategory22','Subcategory22');
		g_form.addOption('subcategory','Subcategory23','Subcategory23');
	}
	else if(newValue =='Category 3')
	{
		g_form.clearOptions('subcategory');
		g_form.addOption('subcategory', '', '-- None --');
		g_form.addOption('subcategory','Subcategory31','Subcategory31');
		g_form.addOption('subcategory','Subcategory32','Subcategory32');
		g_form.addOption('subcategory','Subcategory33','Subcategory33');
	}	
}