Run The Transform Map Only If There's Incoming Record

Himesh Murthy
Tera Contributor

Hello,

I had a requirement to integrate Servicenow and a 3rd party tool via Data source of type JDBC which is working fine as expected to fetch the data from 3rd party tool and update/create records within Servicenow custom table. This custom table has got an active field which will make the incoming records active otherwise inactive. To achieve this inactive/active mehanism of records, we are making all the records on the custom table inactive using onstart transform script post which all incoming records will be made active using field maps

This Data source has been included in the scheduled imports to run on a daily basis. Is there a way to stop running this transform map if there are no records incoming as this is making all records inactive when the Mid Server is down and not running ?

In simple terms my ask here is "I want to run the transform map only if there are records incoming otherwise not". Please let me know if there's a way to achieve this. Thanks

 

Regards,

Himesh

4 REPLIES 4

rubina khatun2
Tera Expert

Hi @Himesh Murthy 

you need to write find_real_file.png  under your Data source  with the condition.

find_real_file.png

 

Please mark my Answer correct if it is resolve your query 

 

 

Hello @rubina khatun ,

Thanks for the quick response.

May I know what script logic must be written in the condition to get the record count please?

Hi @Himesh Murthy 

@Ankur Bawiskar is correct you can write script .

create a new Tag (label) record : System Definition >Tags>new

----------------------------------- Transform Script When: onBefore ----------------------------------

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
  
  var tagSysId = 'tag Sys_ID';

  if (action == 'insert') {
      var gr = new GlideRecord('label_entry');
      gr.initialize();
      gr.table = target.getTableName() + '';
      gr.label = tagSysId;
      gr.table_key = target.sys_id + '';
      gr.title = target.getDisplayValue();
      gr.insert();
  }

--------------------------------------------------------------------------

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can check if the import set table has records or not in onStart and ignore the entire transformation if no rows.

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader