transform script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-07-2023 04:05 AM
am having a transform script where i update approval set Date time field type on customer project table
basically, if the import set has values other than dates leave it blank else fill it with the date
The 1st time its happening correct (like blank when no date and date when present)
but after that if i test it by making a row blank , after a date is filled , the previous value is set and not blanking. any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-07-2023 04:59 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-07-2023 05:01 AM
Try:
var gdt = new GlideDateTime(source.u_opening_date);
gs.log("GDT--> "+gdt);
var openDate = new GlideDateTime();
gs.log("OPEN DATE-> "+openDate);
if(gdt == null || gdt == '')
{
openDate = 'NULL';
gs.log("inside null Loop-> "+openDate);
}
else
{
gs.log("inside else-> "+openDate);
var seconds = 18*60*60;
gdt.addSeconds(seconds);
openDate = gdt.getValue(); // return the value to be put into the target field
gs.log("OPEN DATE after Setting-> "+openDate);
}
gs.log("OPEN DATE after Setting finallllly-> "+openDate);
return openDate;
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-07-2023 05:16 AM
Unable to format NULL using format string yyyy-MM-dd HH:mm:ss for field approval_set

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-07-2023 05:26 AM
Then I think you won't be able to do this using a scripted field map.
Use a before transform script:
Use target.setValue('opening_date', '') in your else, or target.setValue('opening_date', openDate) instead of return openDate
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.