The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Catalog with 'Available for' as empty

swapnil15
Tera Contributor

Hi everyone,

How to get a list of catalog item names from the 'sc_cat_item' table where the 'Available for' related tab has no records.

 

swapnil15_0-1713282931175.png

 

3 REPLIES 3

Deepak Shaerma
Kilo Sage

Hi @swapnil15 

try edit in catalog builder ,
Determine the correct table and relationship that defines what “Available For” means. This might involve a many-to-many table or a condition based on user or group relationships.
The script is hypothetical as the specific tables and relationships for “Available For” need to be identified.

Business rule or use it in background script

var catItemsWithoutRelatedRecords = [];
var catItemGR = new GlideRecord('sc_cat_item'); // Catalog Item table

catItemGR.query();
while(catItemGR.next()) {
    var relatedRecordGR = new GlideRecord('related_table'); // The related table that defines “Available For”
    relatedRecordGR.addQuery('catalog_item', catItemGR.sys_id); // Assuming the relationship is stored here
    relatedRecordGR.query();
    if (!relatedRecordGR.hasNext()) { // No related records found
        catItemsWithoutRelatedRecords.push(catItemGR.getValue('name')); // Collecting item names
    }
}

// Example output to log (or adapt to your needs)
gs.info(‘Catalog Items without related records: ’ + catItemsWithoutRelatedRecords.join(’, '));



Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 

Ranjit Nimbalka
Mega Sage

Hi @swapnil15 ,

 

Below thread on community might help you.

https://www.servicenow.com/community/developer-forum/list-of-empty-available-for-catalog-items/m-p/2...

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Ranjit

Brian Lancaster
Tera Sage

You would probably have to create a Database view between the two tables with a left join.