Hi Community, we need to surpress the portfolios for only on sc_cat_item

rajeshKongamudi
Tera Contributor

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

rajeshKongamudi_0-1743748818563.png

 

2 REPLIES 2

Vishal Jaswal
Giga Sage

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!

Rohit  Singh
Mega Sage

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