Update target with a null value if the source is null from transform map

Community Alums
Not applicable

Update target with a null value if the source is null from transform map with out using 'Copy Empty Fields'

 

I have used below script but it is not working, could I get some help here please

answer = (function transformEntry(source,target) {

//var gdt = new GlideDateTime(source.u_last_day);
//return gdt.getValue();
//if (source.u_last_day == '') {
if (source.u_last_day.nil()){
target.u_last_day == '';
}

})(source);

22 REPLIES 22

Community Alums
Not applicable

Hi Ankur,

Thank you! I tried that too but it did not work 

RJ8_0-1676454321927.png

 

@Community Alums 

if it's not setting empty date then what value it is setting?

Did you check any default value is present for that field?

Any Before insert/update BR is setting some value in that field?

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

Community Alums
Not applicable

We have dates already present on our u_last_day table in the sys_user table and want to replace them with blank if transform map sends blank values, but its not replacing with blank.

 

Thanks

RJ

@Community Alums 

then script I shared in the onBefore is correct.

try to make some other field as empty using target object

I hope your transform map is on sys_user table only

 

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

Community Alums
Not applicable

Hi @Ankur Bawiskar 

Yes, my transform map is on sys_user table. The onBefore script worked for other field (type = string), but its not working on a date field.

 

Thanks