Transform map...scripting

matthew_magee1
Giga Guru

Hello all,

I'm drawing a blank on this.

Here's the scenario:

  1. I have an excel doc w/ 5000+ records
  2. Each record is categorized by 'device type' (router, server, chassis, etc)
  3. I've loaded the data just fine
  4. I created a transform map for 'chassis' only
  5. I'll create other transform maps for the other device types
  6. Source table == loaded data table
  7. Target table == custom Chassis table
  8. In this transform map, I've created the field maps (this is goodness)
  9. I checked 'Run Script' because I only want to import records into the Chassis table where source.u_device_type == 'Chassis'
  10. PROBLEM: what do i put in the script window to only look at the records in the import table where device type == 'Chassis'?

Thanks!

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Matthew,



You should have the logic in the transformation script of type "OnStart" i.e when field should be OnStart.


Transform Map Scripts - ServiceNow Wiki


akash_mehta
ServiceNow Employee
ServiceNow Employee

Matthew:   As Pradeep said you can use the OnStart Script...the run script that you mention will work also.   In the script you need an if statement:



if(source.u_YOUR_FIELD_HERE != 'Chassis'){


ignore = true;


}



This will move pass that record and on to the next.


Jaspal Singh
Mega Patron
Mega Patron

Hi Matthew,



You can also script it when you create a transform map. Something as below


find_real_file.png


with script as mentioned by Akash in the trail above. Else you can also use OnStart as mentioned by Pradeep.


matthew_magee1
Giga Guru

All-



I ended up doing an onBefore Transform Map Script because with onStart, if 'ignore' comes back with a 'true' response, the rest of the import is ignored. If I use onBefore, and ignore = 'true', then just that record is ignored and it continues with the import.



all is good so far



Thanks much