Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to ignore records in IntegrationHub ETL based on some criteria for a attribute?

Suggy
Giga Sage

How to ignore records in IntegrationHub ETL on some criteria using the On Before script?

Docs says to refer the guidance mentioned here but couldnt get it done.

https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/configuration-manag...

 

Ex - There is an attribute called 'Environemnt'.  If it contains the keyword 'dev', then that row should be completely ignored.

 

 

5 REPLIES 5

Thanks a lot @DrewW 

Hi @DrewW 

This is what the guidelines says when I click on that 'On Before' script. The link whihc you gave is not reflecting what is shown in the instance.. Can you please help.

 

/**
  *
  * Script executed for a given batch before calling the Identification and Reconciliation Engine (IRE)
  *
  * The following variables are available to the script:
  *    'input' - the array where each element of the input array is an object. Each object contains a status, reason, and payload.
  *    'runId' - the current import set run id.
  *
  * Example:
  */
 // (function(input, runId) {
 //     for (var i = 0; i < input.length; i++) {
 //         // Skip all payloads which have a computer starting with name as 'TEST-'
 //         if (!isComputerNameValid(input[i].payload)) {
 //             input[i].status = 'SKIPPED';
 //             input[i].reason = 'Skipping IRE processing of this payload.';
 //         } else {
 //             // Add new value to items
 //             input[i].payload.items[0].values.short_description = 'Adding missing description';
 
 //             // Add a new relationship by passing a JSON object (Use unshift() to add a relationship at the beginning)
 //             // Similarly, any relation can be removed by using the pop() or shift() methods
 //             var relation = {
 //                 'parent': 0,
 //                 'child': 1,
 //                 'type': 'Runs on::Runs'
 //             };
 //             input[i].payload.relations.push(relation);
 
 //             // Update an existing reference item by passing a JSON object.
 //             // Similarly, the entire reference items array can also be updated e.g. input[i].payload.referenceItems = {...}
 //             input[i].payload.referenceItems[0] = {
 //                 'referenceField': 'software',
 //                 'referencedBy': 'internal_id2',
 //                 'referenced': 'internal_id1'
 //             };
 //         }
 //     }
 // })(input, runId);
 
 // function isComputerNameValid(payload) {
 //     for (var i = 0; i < payload.items.length; i++)
 //         if (payload.items[i].className == 'cmdb_ci_computer' && payload.items[i].values.name.startsWith('TEST-'))
 //             return false;
 //     return true;
 // }
 /**
  * The following properties/functions are available for all parameters of type 'Array' inside the IRE payload e.g. items, relations, referenceItems, lookup and related:
  * length - Returns the number of elements in an array
  * push() - Add an item to the end of an array
  * pop() - Remove an item from the end of an array
  * shift() - Remove an item from the beginning of an array
  * unshift() - Add an item to the beginning of an array
  *
  * Important points:
  * 1) The before script is executed once per batch and not per payload. The input array elements contain all the payloads for a given batch.
  * 2) Each element in the array has only 3 fields i.e. status, reason, and payload. Adding additional fields to the array elements might result in unexpected errors.
  * 3) The 'status' can be set to 'SKIPPED' in order to skip a payload in this batch from further processing. Setting 'status' to any other value will be ignored by the RTE processor.
  * 4) Optionally, a 'reason' can be set for skipping the payload. This will be the message on the import set run for this particular row.
  * 5) To match the batch size after script execution, only the length property is available for input array e.g. input.length
  * 6) Using any of the above functions e.g. push(), pop(), shift() and unshift() on input array directly will result in unexpected errors.
  *
  * Below is an example of an IRE input payload. There can be more fields/parameters depending on each use case. Refer to the ServiceNow Product Documentation for more examples on the IRE payload.
  * {
  *  'items': [
  *    {
  *      'className': 'cmdb_ci_computer',
  *      'values': {
  *        'name': 'Macbook Pro 15',
  *        'os_version': '5.1.2600',
  *        'ram': '2048',
  *        'disk_space': '1024'
  *      }
  *    }
  *  ]
  * }
  */

 (function(input, runId) {
 
     //Add your code here

 })(input, runId);

Hi @Suggy ust wondering whether you found an answer to this. 

 

Thanks