Hi Community, we need to surpress the portfolios for only on sc_cat_item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 11:40 PM
We are attempting to implement a Before Query Business Rule on the Portfolio table that filters out records based on their association with Service Catalog Items (sc_cat_item). Specifically, when the “Apply to Catalog Item” field is set to true, we want to ensure that any Portfolio referenced in Catalog Items is automatically excluded from query results—but only when the query originates from the sc_cat_item table.
The goal is to dynamically add a filter to hide these Portfolios during selection in Catalog Items, while ensuring that this rule does not impact queries from other tables. (Note: instead of using reference qualifier we need some automation process here)
We are currently using a script and a system property to retrieve the calling table name and construct the query accordingly. However, we are encountering challenges ensuring that the filtering applies only to the sc_cat_item context, without affecting other tables.
Could you please assist us in refining the approach or suggest a solution that meets the above requirement?
(function executeRule(current, query, scope) {
// Get the name of the referring table
var refTable = '' + gs.getProperty('glide.sys_reference_table');
// If Portfolio is being referenced in a Catalog Item form, apply the filter
if (refTable === 'sc_cat_item') {
query.addQuery('u_apply_to_catalog_item', false); // Only show portfolios not marked as "apply"
}
})(current, query, scope);
Sys_property: pls correct weather i'm using correct value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 11:56 PM
Hello @rajeshKongamudi
If you want to use the same code then change your system property name from catalog item suppression to glide.sys_reference_table
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2025 03:49 AM
Hi @rajeshKongamudi ,
You need to update the system property name in your script.
Please try below code.
(function executeRule(current, query, scope) {
// Get the name of the referring table
var refTable = '' + gs.getProperty('catalog item surpression');
// If Portfolio is being referenced in a Catalog Item form, apply the filter
if (refTable === 'sc_cat_item') {
query.addQuery('u_apply_to_catalog_item', false); // Only show portfolios not marked as "apply"
}
})(current, query, scope);
If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Rohit