Instead of using two if statements, you might want to try:
if (!doc['start_date'].empty && !doc['last_update'].empty)
Your script would look like:
if (!doc['start_date'].empty && !doc['last_update'].empty)
{
def time_diff = doc['last_update'].value.millis - doc['start_date'].value.millis;
def minutes = time_diff / 60000;
// minutes > 30 ? 'Open': 'Closed'
if ( minutes > 30 )
{
return 'Open'
} else {
return 'Closed'
}
}
This topic explains a similar issue: Painless, if two field exists then calculate