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-14-2023 06:13 PM
Hi @Community Alums ,
Change target.u_last_day == ''; to target.u_last_day = '';, basically what == does is it checks and evaluates and returns true or false, not assigning value to a variable.
Please mark correct if this helped your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 12:15 AM
Hi Kirby,
Thanks for the response.
I tried changing to target.u_last_day = ''; but its still not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2023 09:37 PM
@Community Alums Hello,
Please make following change at line 6:
target.u_last_day = '';
Please mark the answer as correct if it solves your question. Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 12:49 AM
@Community Alums
use onBefore transform script
I hope the target field name is correct i.e. u_last_day
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(source.u_last_day.nil())
target.u_last_day = '';
})(source, map, log, target);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader