onChange Client Script causing Javascript Error on Service Portal view but not Core UI view

WazzaJC
Tera Expert

onChange Client Script causing Javascript Error on Service Portal view but not Core UI view

 

Hi Guys - can anyone please help provide guidance/advice on this one. (please see screenshots attached and Script embedded in message below).

 

I am using the following onChange Client Script which works fine in Core/Native UI view but not on the Service Portal view?

 

When on Service Portal view I get Javascript Error messages but yet the Script works fine in the Native UI view.

 

Can you see anything in my script that is incorrect that needs changing for Service Portal view ?

 

Many thanks.

This is the script:

 

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

    {
        //Change the 'Service Offering' name if necessary, for each specific 'case'
        var service_offering = g_form.getDisplayBox('service_offering').value;

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

                break;

            case 'PDS - BO - Communication Services':
                g_form.setValue('category', "software");

                break;

            case 'PDS - BO - Productivity':
                g_form.setValue('category', "software");

                break;

            case 'PDS - BO - Collaboration':
                g_form.setValue('category', "software");

                break;

            case 'PDS - BO - Business Hardware Support':
                g_form.setValue('category', "hardware");

                break;

            case 'PDS - BO - User Cyber Services':
                g_form.setValue('category', "security");

                break;

            case 'PDS - BO - Infrastructure Maintenance':
                g_form.setValue('category', "network");

                break;

        }
    }
}

 

  

2 ACCEPTED SOLUTIONS

OlaN
Giga Sage
Giga Sage

Hi,

It's the g_form.getDisplayBox() that causes the error.

Try using g_form.getDisplayValue() instead.

You can find more details on the Developer site.

 

View solution in original post

Small correction:

 

var service_offering = "";

if(g_form.getDisplayBox){
service_offering = g_form.getDisplayBox('service_offering').value;
}else{
service_offering = g_form.getDisplayValue('service_offering');
}
If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

6 REPLIES 6

Small correction:

 

var service_offering = "";

if(g_form.getDisplayBox){
service_offering = g_form.getDisplayBox('service_offering').value;
}else{
service_offering = g_form.getDisplayValue('service_offering');
}
If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

This is excellent - this works perfectly - I have it up and running!

 

Again, thanks very much Ahmmed, much appreciated kind sir.