Hi,
I have this code where if the index points are not returned, it should return the default value. But instead it returns empty data.
How do I make sure that the default value is returned
a!localVariables( local!address1: {{id:1},{id:2}}, local!mdmAddress:{{id:5,name:"abc"},{id:3,name:"pqr"}}, index(local!mdmAddress, wherecontains(local!address1.id,local!mdmAddress.id),"Hello" ) )
Discussion posts and replies are publicly visible
Hi There,
In such cases, it is always best to add a null check. E.g. Instead of retuning "Hello", please return a null and then in another variable, using an if condition, add a null check to return "hello" in case the indexed property is null or does not exists. Also, please consider creating a custom nullCheck rule that treats null, empty string, and empty list as null.
Unknown said:using an if condition
And now in 21.2 they've made this even easier since we have a!defaultValue(), such things no longer need to be wrapped in an IF() statement.
Oh yes! How can I forget that But I wonder, does it checks for blank string and blank list too?
I've tested it a bit and it seems like it handles most corner cases well. I may have forgotten some of course.