Close
Thank you for your feedback.

Create a record producer filter configuration using scripting

Create a record producer filter configuration using scripting

You can create a filter with scripting mapped to a record producer configuration to improve search results.

Before you begin

Role required: admin

Procedure

  1. Navigate to Contextual Search > Record Producer Configuration.

  2. Select a record producer configuration on which to create the filter (for example, Create Case, Create Incident, etc.).

  3. From the Filter Configurations related list, click New.

  4. Fill in the Search resource field on the Record Producer Filter Configuration form with the resource to be searched (for example, knowledge, social, etc.).

  5. Click the Active check box.

  6. Click the Enable advanced filtering using script check box.

  7. Add script content to the Script for Filter section to configure the filter.

  8. Click Submit.

Example

(function buildFilter(producer) { 
// 'producer' is a GlideRecord instance of the 'Source record producer'. 
// The return is an encoded query that will be executed on the 'Search resource table'. 

/*
The sample script below addresses the following scenario: 
   - The 'Source record producer' is of type 'Create Case' and has a field called 'asset' that refers to the table 'alm_asset' 
   - The 'Search resource table' is of type Knowledge [kb_knowledge] and has a field called 'u_product' that refers to the table 'cmdb_model' 
   - Out of the box 'alm_asset' has a field called 'model' that refers to the table 'cmdb_model' 
   - Based on the asset provided in the case, we will derive the 'model', and use that to filter Knowledge Articles for that 'model'. */
 
	 /*
	 var filter = ""; 

	 //Logic to build encoded query filter here. Build filter only if user has entered an "asset" 
	 if(producer.asset) { 
		 // u_product is a custom field in Knowledge Table. 
		 filter += "^u_product=" + producer.asset.model; 
	 } 

	 return filter; */

 })(producer);

Products > Service Management > Customer Service; Versions > Istanbul