Limiting the search to not show specific Record Producers

kevinbruneau
Tera Contributor

Hi all,

 

I was wondering if anyone else using the Typeahead Search widget was able to limit it's search?

 

I am asking because sometimes we need to have access to some of the forms/record producers without having users able to find them via the search bar... We thought that by removing them from the taxonomy would of been enough, but users can still search for those Record Producers and submit them.

 

kevinbruneau_0-1742470908795.png

 

Thanks,

 

Kev

 

 

1 REPLY 1

pratikjagtap
Giga Guru

Hi @kevinbruneau ,

 

teps to Modify the Data Source:

  1. Navigate to: Service Portal > Widgets

  2. Find the Typeahead Search widget and open it.

  3. Look for the Server Script tab, which contains the query logic.

  4. Modify the script to filter out certain Record Producers.

Script:

 

(function() {
var query = "active=true"; // Only show active items

// Exclude specific Record Producers
query += " AND sys_idNOT IN ('sys_id_1', 'sys_id_2')";

var gr = new GlideRecord("sc_cat_item");
gr.addEncodedQuery(query);
gr.query();

var results = [];
while (gr.next()) {
results.push({
name: gr.getValue("name"),
sys_id: gr.getValue("sys_id"),
type: "record_producer"
});
}

data.results = results;
})();

 

 

  • Replace 'sys_id_1', 'sys_id_2' with the actual sys_id of the Record Producers you want to exclude.
  • This will prevent those items from appearing in the search results.

If this solution helps you then, mark it as accepted solution ‌‌✔️ and give thumbs up 👍 !

 

Regards,

Pratik