- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 01:57 PM
Hello dear experts,
I want to display a short description field if there are more than 3 options selected in the right bucket of the list collector, but my code isn't working in the service portal. Its probably because the gel function doesn't work for portal. The below is the code that works in the native view and doesn't in the Service Portal:
function onChange(control, oldValue, newValue, isLoading) {
if(isLoading)
return;
var varName = 'swItem_costcenter';
var rightBucket = gel(varName + '_select_1');
var selectedOptions = rightBucket.options;
var len = selectedOptions.length;
// Determine if more than 1 cost center is selected, if so cost distribution should be determined
if( len > 1){
g_form.setDisplay('swItem_cost_distribution', true);
g_form.setMandatory('swItem_cost_distribution', true);
}else{
g_form.setDisplay('swItem_cost_distribution', false);
g_form.setMandatory('swItem_cost_distribution', false);
g_form.setValue('swItem_cost_distribution', '');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 05:33 AM
Thanks everyone. I was able to do this with the use of of the Split function. Values in the right bucket in the List Collector are separated by commas. I was able to make use of that fact.
Here's the code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setDisplay('swItem_cost_distribution', false);
g_form.setMandatory('swItem_cost_distribution', false);
g_form.setValue('swItem_cost_distribution', '');
return;
}
value = g_form.getValue('swItem_costcenter');
len = value.split(',').length;
// Determine if more than 1 cost center is selected, if so cost distribution should be determined
if( len > 1){
g_form.setDisplay('swItem_cost_distribution', true);
g_form.setMandatory('swItem_cost_distribution', true);
}else{
g_form.setDisplay('swItem_cost_distribution', false);
g_form.setMandatory('swItem_cost_distribution', false);
g_form.setValue('swItem_cost_distribution', '');
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Thanks again everyone!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 02:13 PM
Hello Jaison,
You may find the below thread helpful.
Re: What is the alternative for gel() on service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 02:51 PM
In addition, once you've sorted out/converted gel, you would need to set the Catalog Client script's UI type to 'Both' (Helsinki) or 'All' (Istanbul) for your scripts to work in service portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 09:35 PM
Regina - Thanks for that. Yes I've already set the UI Type of the Client script in the Istanbul instance as 'All'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 10:01 PM
Hi Jaison
Can u pls go through this link