- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:25 AM - edited 07-26-2023 02:28 AM
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;
}
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:33 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:45 AM
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');
}
Thank you,
Ali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:33 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 03:43 AM
Thanks very much OlaN. This is great, I have it working now after changing as per your guidance.
I appreciate your help kind sir.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:47 AM - edited 07-26-2023 10:48 AM
Glad I could help you, thank you for your kind words! 😀

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:42 AM
Hello @WazzaJC
Change
var service_offering = g_form.getDisplayBox('service_offering').value;
to
var service_offering = "";
if(g_form.getDisplayBox('service_offering')){
service_offering = g_form.getDisplayBox('service_offering').value;
}else{
service_offering = g_form.getDisplayValue('service_offering');
}
Thank you,
Ali
Thank you,
Ali