Clear DateTime field during Transform

Todd_Goodhew
Kilo Guru

Thanks in advance for any help. This one has me stumped.

I have a DateTime field on a target table.  During import, I want to clear this field of any value (make it NULL) during import based on the value of a corresponding source field.  

This should be pretty simple with a field map script on the transform, but no matter what I do, I can't seem to clear the target field of a value.  I can set it to another date/time value just fine.  I just can't seem to clear it of any value.

I know the source values exist in the source data and I know that part of the if statement passes true, previous version of the code had logging in it to validate this piece.

Any thoughts?

Here's the code:

answer = (function transformEntry(source) {

	var dtUtil = new DateTimeUtils();
	var value;
	
	// if the account is set to never expire or has no value, then clear out the field
	if ( source.u_accountexpires == '9223372036854775807' || source.u_accountexpires == '0' || source.u_accountexpires === undefined){
		value = '';  // return an empty string to clear out the value.
	} else {
	// otherwise convert the value from the MS Interger8 format to GlideDateTime format and set the target field with it
	value = dtUtil.int8ToGlideDateTime(source.u_accountexpires); 
	}

return value;
	
})(source);
10 REPLIES 10

Bjarke Hedegaar
Giga Contributor

Had the same issue. In the table transform map, the field "Copy empty fields" was set to false. Setting it to true an returning null works for me.