The CreatorCon Call for Content is officially open! Get started here.

Catalog Client Script is Not Working

Community Alums
Not applicable

Hi All,
I have written on change client script for populating category nd subcategory based on the caller company, department and caller email domain.

res[0] - is company and res[2] - is department & res[1] - is email domain 

 

if ((res[0] == 'ES'|| res[0] == 'RES'&& (res[2] != " Business Servic" || res[2] != "Accounts " || res[2] != ' Marketing' || res[2] != " Property Mgmt" || res[2] != " Team")) && (res[1] == 'textiand' || res[1] == 'ddLife')) {

 

Here in my case if i give only one company then my code is working fine but here i want to take two companies 

ie, if i take resi[0]=='ES', then the code is working fine, but i need to take 2 companies here,

 

Please find the below code i have written :

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

    try {

        

        if ( newValue === '') {

            return;

        }

       

        var resFlag = false;

        var userSysid = g_form.getValue('caller_id');

        var ga = new GlideAjax('Incident_caller_details');

 

 

        ga.addParam('sysparm_name', 'get_callerdetails');

        ga.addParam('sysId', userSysid);

        ga.getXML(HelloWorldParse);

 

 

 

        function HelloWorldParse(response) {

 

 

            var answer = response.responseXML.documentElement.getAttribute("answer");

            //alert(answer);

            var res = answer.split(',');

           if(res[2] == "Property Mgmt")

            {

                return;

            }  

           

           

            if ((res[0] == 'ES'|| res[0] == 'RES'&& (res[2] != " Business Servic" || res[2] != "Accounts " || res[2] != ' Marketing' || res[2] != " Property Mgmt" || res[2] != " Team")) && (res[1] == 'textiand' || res[1] == 'ddLife')) {

                           

                     alert('inside the right block');

 

                g_form.removeOption('category', 'Application');

                g_form.removeOption('category', 'Building Maintenance');

                }

           

            if (res[0] != 'ES'&& res[0] != 'RES') {

               

                alert('inside the right block :: Non resal');

 

                g_form.addOption('category', 'Application', 'Application');

                g_form.addOption('category', 'Building Maintenance','Building Maintenance');

              

               

                

            }

 

        if ((res[0] == 'ES' ||res[0] == 'RES' && (res[2] == " Business Servic" || res[2] == "Accounts " || res[2] == ' Marketing' || res[2] == " Property Mgmt" || res[2] == "Team")))

        {

               

               

       

                

                alert('inside the right block :: Ri corp');

 

                g_form.addOption('category', 'Application', 'Application');

                g_form.addOption('category', 'Building Maintenance','Building Maintenance');

               

            }

 

        }

    } catch (ex) {

        

    }

 

}

 

Could you please help me on to get the proper solution.

 

Thanks,

Priya

1 REPLY 1

Saurabh Gupta
Kilo Patron

Hi,
Can you try modify as below

//Your code:
 if ((res[0] == 'ES'|| res[0] == 'RES'&& (res[2] != " Business Servic" || res[2] != "Accounts " || res[2] != ' Marketing' || res[2] != " Property Mgmt" || res[2] != " Team")) && (res[1] == 'textiand' || res[1] == 'ddLife')) 

//Updated Code:
      if (((res[0] == 'ES'|| res[0] == 'RES')&& (res[2] != " Business Servic" && res[2] != "Accounts " && res[2] != ' Marketing' && res[2] != " Property Mgmt" && res[2] != " Team")) && (res[1] == 'textiand' || res[1] == 'ddLife')) {

Thanks and Regards,

Saurabh Gupta