- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 12:17 AM - edited 11-18-2022 01:05 AM
I am using a variable set and I am filtering conditions like
Application<category<sub-category
if there is no application then category<sub-category
javascript: 'u_type=category^u_inactive=false^u_catalog_item='+(current.cat_item.sys_id||current.request_item.cat_item.sys_id)+'^u_application='+current.variables.application;
This will work only if user select application
How can I use it if the application is empty set the application as empty?
if(current.variables.application){
return current.variables.application;
}else{
return '';
}
I created like this
javascript:if (current.variables.application != "") 'u_type=category^u_inactive=false^u_catalog_item='+(current.cat_item.sys_id||current.request_item.cat_item.sys_id)+'^u_application='+current.variables.application;else 'u_type=category^u_inactive=false^u_catalog_item='+(current.cat_item.sys_id||current.request_item.cat_item.sys_id);
but else part not working
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:36 AM
use this
javascript: var query; if (current.variables.application != "") query = 'u_type=category^u_inactive=false^u_catalog_item='+(current.cat_item.sys_id||current.request_item.cat_item.sys_id)+'^u_application='+current.variables.application; else query = 'u_type=category^u_inactive=false^u_catalog_item='+(current.cat_item.sys_id||current.request_item.cat_item.sys_id); query;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:42 AM
else part not working.
If no application category is not populating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:55 AM
are you having any category records satisfying the query in else
then only it will work
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:58 AM
yes we have but still not showing values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 02:13 AM
javascript: var query; if (!current.variables.application) query = 'u_type=category^u_inactive=false^u_catalog_item='+(current.cat_item.sys_id||current.request_item.cat_item.sys_id); else query = 'u_type=category^u_inactive=false^u_catalog_item='+(current.cat_item.sys_id||current.request_item.cat_item.sys_id)+'^u_application='+current.variables.application; query;
working fine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 02:18 AM
it's similar to what I suggested above you just swapped the query based on if condition
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader