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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2023 02:55 PM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 01:45 AM
Hi Ankur,
Thank you! I tried that too but it did not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 02:34 AM
@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?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 06:30 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 07:24 AM
@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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 08:12 AM
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