Check for empty field when performing transform
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2018 11:19 AM
Hi,
We have a number of data sources within my organisation and we are currently performing manual load & transforms. I would like to have some fields updated based on one of the target fields being empty.
This is my script
//Verify that Discovery Source is not empty
if(!target.discovery_source.isnil()) {
target.discovery_source = 'EO Master Sheet';
target.first_discovered = gs.nowDateTime();
target.last_discovered = gs.nowDateTime();
} else {
//If not empty then set Last Discovered to today
target.last_discovered = gs.nowDateTime();
}
If anyone can shed any light into where I am going wrong, it would be much appreciated.
Regards
Lee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2018 07:02 AM
You beat me to it. I looked at that line several times, and wondered
if (!field.nil())
That tells if it is NOT empty, which is when you want to set the last date only. 🙂
The other option would have to been keep the condition and flip the statements from the top to the bottom so last is only being set in the top if the !nil() condition is true.
Glad you got it figured out.