Sunday 3 January 2016

Fusion CRM Groovy Examples - How to do null check

Oracle sales cloud groovy has a very good support for null check. Below points give you some idea about it.

How do we access property of a child collection?

def childCollection = parentObject.childCollection

If you use above code, there is a potential chance for nullpointerException at runtime, So better use the null-safe question mark (?)

def childCollection = parentObject?.childCollection

Also you can use nvl function to check for null values in conditional statements

if (nvl(DiscountAmount_c, 0) > 50 )
{
. . . . . . . .. . . .
......................
}