- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hello All,I have the following setup, but Variable 2 isn’t working as intended. I’d like advice on how to fix or improve it.
Configuration:
Variable 1 (directly under the Catalog Item)
- Name: va_category
- Type: Reference
- Type specifications:
- Reference: sys_choice
- Use reference qualifier: Advanced
- Reference qualifier:javascript:"element=category^name=incident^inactive=false^language="+gs.getUser().getLanguage();
Variable set: vs_subcategory_details
Variable 2 (inside the variable set)
- Name: va_subcategory
- Type: Reference
- Type specifications:
- Reference: sys_choice
- Use reference qualifier: Advanced
- Reference qualifier (not working):javascript:"name=incident^element=subcategory^inactive=false^dependent_value="+current.variables.va_category.value+"^language="+gs.getUser().getLanguage()
I want Variable 2 to show only the subcategories for the category selected in Variable 1.
This works if both variables are directly under the catalog item, but it fails when Variable 2 is inside a variable set.
If this is achievable, could you please advise on the correct approach or best practice?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
correct, that's the reason.
we are storing sysId but the ref qualifier requires the value of that choice
you can do this in your onLoad catalog client script
function onLoad() {
var cat = g_service_catalog.parent.getValue("va_category");
// use GlideAjax here and pass the sysId and query sys_choice with that sysId and return value and then set in hidden field
g_form.setValue('hiddenVariableName', cat);
g_form.setDisplay('hiddenVariableName', false);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
is that variable 2 under Single row variable set or Multi row variable set?
share screenshots
if it's under Single row variable set then it should work fine
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
@Ankur Bawiskar ,Multi row variable set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
then it's not going to work directly.
Do this
-> in your multi-row variable set create a string type variable with highest order so that it comes at bottom of row
-> create onLoad catalog client script which Applies to multi row variable set and use this script, what it does is it will set the variable 1 value in your string variable
-> then you can use the value in new variable in your Variable 2 ref qualifier
function onLoad() {
var cat = g_service_catalog.parent.getValue("va_category");
g_form.setValue('hiddenVariableName', cat);
g_form.setDisplay('hiddenVariableName', false);
}
then update ref qualifier as this on 2nd variable
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Thank you for marking my response as helpful.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
