- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 02:45 PM
To All Helsinki and Service Portal Users,
The Issue: Record Producer is not populating dependent variables in the Service Portal like it does in the Native UI
Assumptions: Related to the applied Client Script that isn't running in the Service Portal
Service Portal Results:
I have record producers available in the Service Catalog with dependent fields based on a client script that is currently applied. In the record producer, the "Category" is defaulted and passes to the incident ticket's Category field. The subcategory populates based on category that is defaulted, which also passes to the Subcategory field on the incident ticket. Here is how it looks in the record producer form:
Here's the behind the scene things:
Record Producer Script to pass the category and sub to the incident ticket:
Catalog Client Script applied to the record producer to filter the Subcategory based on the Category
If anyone has any idea why the client scripts applied to the record producer do not function as they should in the Service Portal, please let me know!
Also, if any further information is needed, I am more than willing to provide it
Thank you all,
-Marques
Solved! Go to Solution.
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 10:14 PM
Hi Marques,
The issue here is that your GlideRecord query is still synchronous and needs a call back function. When you mark it as "mobile" or "both" you have to update all your script to use the mobile version of the API.
Here is the modified script.
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
//remove all items from subcat drop down to start
// Used the g_form.clearOptions() function instead of g_form.removeOption() function
g_form.clearOptions('subcat');
//build a new list of dependent options
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'subcategory');
gp.query(function(gp) {
while(gp.next())
g_form.addOption('subcat', gp.value, gp.label);
});
}
Please let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 02:52 PM
Did you set you catalog client script UI type to 'Both'?
Check here for some good info:
documentation/client_scripting.md at master · service-portal/documentation · GitHub
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 02:53 PM
Sorry, just looked at your image above, noticed that it is set correctly...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 10:14 PM
Hi Marques,
The issue here is that your GlideRecord query is still synchronous and needs a call back function. When you mark it as "mobile" or "both" you have to update all your script to use the mobile version of the API.
Here is the modified script.
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
//remove all items from subcat drop down to start
// Used the g_form.clearOptions() function instead of g_form.removeOption() function
g_form.clearOptions('subcat');
//build a new list of dependent options
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'subcategory');
gp.query(function(gp) {
while(gp.next())
g_form.addOption('subcat', gp.value, gp.label);
});
}
Please let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2016 11:55 AM
Hey Pradeep,
Thanks for the reply. I attempted to apply the script above but it broke the filtering in the Native UI. The subcategory is not longer dependent on the value the category displays. Now all subcategory options are available. I'm not sure what is making it do this but it's not working as expected.
Any other ideas?
-Marques