Question on Company and Department Variables on Catalog Form

Priyadarshini M
Tera Contributor

Hi There,

 

I have one Requirement on Termination Catalog Item, 

 

in that form i have company variable and Department variable,

 

and company having some dependent departments for Example:

Under HP Company we have IT, Software, Hardware Departments, and etc.

 

now in my case, what I need to achieve is when User select company as HP at that time IT, Software, Hardware these options should only visible.

Not all the other remaining departments should visible,

 

for this I have written Onchange Client Script but which is not working 

please find the below code.

 

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
             if(newValue=='HP'){
         g_form.addOption('new_department''--None--''--None--');
          g_form.addOption('new_department''IT''IT' );
         g_form.addOption('new_department''Software', 'Software');
}
 
PriyadarshiniM_0-1700207530212.png

 

 

Can somebody please help me, how can i get departments based on there companies.

 

Thanks,

Priya

 

 

3 REPLIES 3

Tarandeep Sing2
Tera Contributor

You could use alert() to check what is coming in the newValue during the choice selection and match it with the value for HP choice in the If condition.

Anand Kumar P
Giga Patron
Giga Patron

Hi @Priyadarshini M ,

Add  g_form.clearOptions('new_department'); line before    if(newValue=='HP');

Thanks,

Anand

 

Tai Vu
Kilo Patron
Kilo Patron

Hi @Priyadarshini M 

Avoid using a client script for this approach. Consider a scenario where you have a thousand companies, would you really want to implement a thousand IF-ELSE statements in the client script? 

How is the relationship between companies and departments currently handled in your instance?

 

Cheers,

Tai Vu