I just want to understand why list of records(0 items) is not returning null/true in below scenarios.
I have problem returning the List of Empty Records to be empty/null.
Any thoughts??
We always practiced using null vs 0 vs "" vs {} depending on the type of data. However here {} for set of array records is not working to identify as null. Of course same behavior with CDT's as well.
Discussion posts and replies are publicly visible
This is the known behaviour of a!isnull() and a!isnullOrEmpty() also, as it probably uses length() function to check if a value is null which would return 1 for a null CDT or record. You can consider it as a best practice to use the below code to check null values for CDTs and Records specially.
{ a!isNullOrEmpty({}), cast(type!Map,{}) = a!map(), cast('recordType!{aa4ce38f-1a9d-4827-af51-e2ccb80a2c8b}AS Vehicle',{}) = ri!value, cast(type!{urn:com:appian:types:PA}PA_AA_VEHICLE,{}) = ri!cdt }
The primitive isnull() function is a bit finnicky with respect to what it considers "null" - in Appian, arrays are a totally different data type from single values, and an empty array has never technically counted as null according to isnull(). In older days we were encouraged to set up a separate expression rule like "rule!apn_isBlank()" which would do a more robust test for null / blank / empty, returning a more intiutive return when fed (for example) an empty list of query result, or other sorts of potentially-empty values. These days however, we have a!isNullOrEmpty() which accomplishes at least (i'll estimate) 80 - 90% of the corner-case handling that we formerly needed to use a specialty expression rule for (there remains a particular corner case, which I don't remember off the top of my head).
I recently wrote a blog post about NULL checks. You find it here: appian.rocks/.../
Thank you for your response Sanchit
Thank you Mike,
I tried this to fix my problem and worked!!
= or( ri!singlePV = "", isnull(ri!singlePV), a!isNullOrEmpty(ri!singlePV) )
Thanks Stefan, this is very informative!!
all(a!isNullOrEmpty(_), a!flatten(ri!value)) --> this worked too!