Transform Map Ignore Insert on Specific Fields

ConnorServiceNo
Tera Contributor

Hello Everyone,

I will be uploading asset data into ServiceNow using an Excel spreadsheet and a transform map. I am trying to determine if it possible to restrict new records being inserted on the associated tables during the upload. The asset information should only be updated with data that exists on the associated tables.

For example, if the spreadsheet had a model that wasn't in ServiceNow as a record, I would want that insert to be ignored.

Please let me know your thoughts on what the best way to go about this would be. My understanding is that you can configure an onBefore Transform map to potentially do something like this but I don't know where to begin. Thank you.

 

Tables that we want to restrict insert on if the record doesn't exist in the table.

  • Location
  • Stockroom
  • Model
  • Model Category
1 ACCEPTED SOLUTION

Ok..I think I understand waht you are saying.

 

Make sure you have the choice action set to ignore for those field mapping, as shown below

 

find_real_file.png


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

5 REPLIES 5

SanjivMeher
Kilo Patron
Kilo Patron

You can write an onBefore transform script, for ex

 

if(action =="insert" && (target.sys_class_name =='cmn_location')){
    ignore = true;
}

Please mark this response as correct or helpful if it assisted you with your question.

Hello Sanjiv,

Thank you for your reply. I have created an onBefore transform script on my existing transform map using the code provided. However even with the new onBefore script, I uploaded a test asset record into my instance with a location that does not exist in the location table and the new record "Funky Town" was created.

find_real_file.png

Ok..I think I understand waht you are saying.

 

Make sure you have the choice action set to ignore for those field mapping, as shown below

 

find_real_file.png


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

Looks like that was the solution. I turned off the onBefore script and just set the Choice action for the location field to be "ignore". When I uploaded an asset record with a location that doesn't exist in the table, the new location was not created. I also tested if it was still going to update the location field if the asset record I upload used an existing location, and the update went through as expected.