How to check if field has a value in a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2015 12:46 PM
I am working within an email script. I tried:
if (gr.work_start.getDisplayValue != null) { template.print(....);}
and
if (gr.work_start.getDisplayValue != "") { template.print(....);}
Both result in the code being executed even if there is no value.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2015 01:24 PM
Since you're just checking if a field value is empty, you don't need to use getDisplayValue(). You can do something like.
if (!gr.work_start) {
//do something
}
The reason your piece doesn't work, even with getDisplayValue is because getDisplayValue is a method and needs to end with ().
So, your line of code would be
if (gr.work_start.getDisplayValue() != null) {
//do something
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2015 01:39 PM
if (gr.work_start) { template.print(....); }
Worked perfectly, thanks!