How to set a Date field to empty when transforming if the source date field in Excel is empty?

mnaranjor
Tera Contributor

I am relatively new to ServiceNow and I am having the following issue when importing data to a table. I have 7 Date fields in my transform map: u_lease_expires, u_purchase_date, u_retired_date, u_warranty_expiration, u_picked_by_beneficiary, u_order_received, and u_loaner_expires.

I noticed that if the field in the Excel file has a value, after the transformation, the correct value transfers to the target table. However if the date field in the Excel value is empty, after the transformation, some target date fields in the table get the following value: 1903-08-13. 

find_real_file.png

find_real_file.png

I matched all the Date fields in the transform map to yyyy-MM-dd format and did the same in Excel. You can see in the first screenshot that this worked by looking at the Purchased Date column. I am running a Transform Script onBefore to clean most of the fields in the target table before adding the data from Excel:

find_real_file.png

I don't know why the rest of the Date fields are getting this value and I am at my wit's end here. Will appreciate some help.

Miguel

 

 

8 REPLIES 8

Abhinay Erra
Giga Sage

You have a checkbox on the transform map called " Copy Empty fields". Check that and you are good to go

I know about this and it is active and still did not work. I also though about it and I unchecked that option.

The thing is that I am trying to populate the alm_hardware table and I am coalescing on the Asset Tag and the Serial Number field. Unfortunately, some of the asset have asset tag number but we cannot see the serial and viceversa. Meaning that both fields cannot be empty at the same time. So, that when I upload the data it will update the field that is empy, but if some field for an asset is already in the table with the correct value, I don't want to import an empty field from the Excel file and override the correct value in the table.

I prefer to try this with a script, so that I can update the table with the fields that are missing without overriding what is correct. I even tried to use the following script...but it did not work

Abhinay Erra
Giga Sage

Did you try to set to empty quotes instead of NULL?

 

target.u_lease_expiration='';

Yes I tried that as well and it did not work. In the import set rows the state says Ignored cause No field values changed.