Catalog client script is not working on the portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2024 01:20 AM
I have the following onChance client script what is working as intended in the backand on the catalog item, but it does not work on the portal.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var businessUnit = g_form.getValue('business_unit');
alert('Business Unit: ' + businessUnit);
if (businessUnit == 'business_unit_sys_id1') {
g_form.removeOption('business_service', 'business serivce sys_id1');
g_form.removeOption('business_service', 'business serivce sys_id2');
g_form.removeOption('business_service', 'business serivce sys_id3');
g_form.removeOption('business_service', 'business serivce sys_id4');
} else {
if (businessUnit == 'business_unit_sys_id2' || businessUnit == '') {
g_form.removeOption('business_service', 'business serivce sys_id1');
g_form.removeOption('business_service', 'business serivce sys_id2');
g_form.removeOption('business_service', 'business serivce sys_id3');
g_form.addOption('business_service', 'business serivce sys_id4', 'Service Name');
}
}
}
On the backend when I open the catalog item, all options are displayed correctly, but on the portal, all options are always displayed, so it is not removing any of the options.
Though the interestng part is that this on load script is actually working on both backend and portal.
function onLoad() {
g_form.removeOption('business_service', 'business ervice sys_id1');
g_form.removeOption('business_service', 'business ervice sys_id2');
g_form.removeOption('business_service', 'business ervice sys_id3');
g_form.removeOption('business_service', 'business ervice sys_id14');
g_form.addOption('business_service', 'business ervice sys_id5', 'Name');
}
As for the settings, the UI type is set to ALL for both scripts, so could somebody help me and explain why the first script is not working on the portal?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2024 05:51 AM
Hi @Wasd123 ,
The issue seems to be in the typo of the business_service value
In onchange client script you are using business serivce sys_id1
g_form.removeOption('business_service', 'business serivce sys_id1');
And in onload client script you have - 'business ervice sys_id1' - The 's' in service is not there, so you need to update the business_service value in onchange client script.
g_form.removeOption('business_service', 'business ervice sys_id1');
Please try this updated code-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var businessUnit = g_form.getValue('business_unit');
alert('Business Unit: ' + businessUnit);
if (businessUnit == 'business_unit_sys_id1') {
g_form.removeOption('business_service', 'business erivce sys_id1');
g_form.removeOption('business_service', 'business erivce sys_id2');
g_form.removeOption('business_service', 'business erivce sys_id3');
g_form.removeOption('business_service', 'business erivce sys_id4');
} else {
if (businessUnit == 'business_unit_sys_id2' || businessUnit == '') {
g_form.removeOption('business_service', 'business erivce sys_id1');
g_form.removeOption('business_service', 'business erivce sys_id2');
g_form.removeOption('business_service', 'business erivce sys_id3');
g_form.addOption('business_service', 'business erivce sys_id4', 'Service Name');
}
}
}
If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2024 12:42 PM
Hi @Community Alums ,
yes, that is correct here, as I have replaced the names and sys_id's from our system I had typo here, though I have checked and compared (within visual studio as well, that the corresponding sys_id's are correct, so at least those should work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2024 10:16 AM
Hi @Wasd123 ,
Please mark below changes in your client script and check than
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2024 12:39 PM
Hi @Community Alums
As I wrote UI Type is set to All.