Name

global.AISearchSourceRefQualUtils

Description

This util class is used to limit the ais search source that can be selected in sys_search_filter and sy_search_source_filter table. The constraint is that selectable ais search sources must come from the same search profile as the sys_search_filter/sys_search_source_filter through sys_search_context_config which links to search profile.

Script

var AISearchSourceRefQualUtils = Class.create();
AISearchSourceRefQualUtils.prototype = {
  initialize: function() {
  },
  
  getRefQualForSearchFilter: function(current) {
  	var gr = new GlideRecord('ais_search_profile_ais_search_source_m2m'); 
  	gr.addQuery('profile', current.search_context_config.search_profile);
  	gr.addQuery('search_source.active', true);
  	gr.query();
  	var ids=[];
  	while (gr.next()) {
  		ids.push(gr.search_source.sys_id);
  	}
  	var result = 'sys_idIN' + ids.join(",");
  	return result;
  },
  
  getRefQualForSearchSourceFilter: function(current) {
  	var gr = new GlideRecord('ais_search_profile_ais_search_source_m2m'); 
  	gr.addQuery('profile', current.search_filter.search_context_config.search_profile); 
  	gr.addQuery('search_source.active', true);
  	gr.query();
  	var ids=[];
  	while (gr.next()) {
  		ids.push(gr.search_source.sys_id);
  	}
  	var result = 'sys_idIN' + ids.join(",");
  	return result;
  },

  type: 'AISearchSourceRefQualUtils'
};

Sys ID

2acbdc555b311010e91728582d81c789

Offical Documentation

Official Docs: