Filter Data

Xhare
Tera Contributor

Hi,

 

I created a catalog item that added data to my custom table which is reference to location table.

I want to filter out the location list if location is already created in my custom table and still active.

How to achieve this requirement?

1 REPLY 1

Community Alums
Not applicable

Hi @Xhare ,

 

You can use the Dynamic Filter Options which is OOTB.

 

The call this reference qualifier wherever its required.

(function() {
    var customTableGR = new GlideRecord('your_custom_table');
    customTableGR.addQuery('active', true);
    customTableGR.query();
    
    var locationIds = [];
    while (customTableGR.next()) {
        locationIds.push(customTableGR.location.toString());
    }
    return 'sys_idNOT IN' + locationIds.join(',');
})();

Give appropriate name and save the record, table should be cmn_location

 

Open the catalog variable and in reference qualifier section select the dynamic option and then select the above created dynamic filter.

SanjayG_0-1717541384154.png

 

save the record and reload the catalog form and validate.

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks & Regards,

Sanjay Kumar