onChange Catalog Client Script Issues

WazzaJC
Tera Expert

onChange Catalog Client Script Issues

 

Hi Guys - I would appreciate any help/advice/guidance on where I am going wrong here.

 

I have an onChange Catalog Client Script (please see screenshots attached) and also I will enclose the Script further below.

 

For some reason, the script is working for the first two selections in my script:

 

So when 'PDS - BO - Database Management' is selected in the catalog form, the 'Category' does get updated to 'Database'.

 

Similary for the second selection, when 'PDS - BO - Business Hardware Support' is selected in the catalog form, the 'Category' does get updated to 'Hardware'.

 

However the third line item/scenario is not working. So when 'PDS - BO - Infrastructure Maintenance' is selected in the catalog form, the 'Category' DOES NOT update to 'Network'.

 

There must be something incorrect in my script code, as the top two scenarios of coding work but not the third scenario?

 

Can you guys see anything obviously wrong in my script/code?

 

Many thanks.

Here is the script code:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    //Change the Service Offering name if necessary	
    var service_offering = g_form.getDisplayBox('business_service').value;

    switch (service_offering) {
        case 'PDS - BO - Database Management':
            g_form.setValue('category', "database");

            break;
    } {
        switch (service_offering) {
            case 'PDS - BO - Business Hardware Support':
                g_form.setValue('category', "hardware");

                break;
        } {
            switch (service_offering) {
                case 'PDS - BO - Infrastructure Maintenance':
                    g_form.setValue('category', "network");

                    break;
            }
        }
    }
}

 

 

1 ACCEPTED SOLUTION

Meloper
Kilo Sage

1. In Switch Case i guess you only need one Switch Expression.

 

switch(expression) {
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
}

 

2. Can you try maybe g_form.addinfomessage (pleased Check command) to get a "Log" and Check If you Script or the Switch Case for that Case works.

What variable type or field field field Type ist category?

View solution in original post

2 REPLIES 2

Meloper
Kilo Sage

1. In Switch Case i guess you only need one Switch Expression.

 

switch(expression) {
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
}

 

2. Can you try maybe g_form.addinfomessage (pleased Check command) to get a "Log" and Check If you Script or the Switch Case for that Case works.

What variable type or field field field Type ist category?

Thanks very much Meloper.

 

You are indeed correct and I have updated my script accordingly.

 

This has solved the issue I was facing.

 

I really appreciate your help and guidance on this one.

 

Kind Regards.