Index default value

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

Parents
  • Hi,

    One of the weird behaviours of index(), When you pass empty array as index it returns all values in the array because it treats the index as a list of empty nested field names (text).

    But if you pass empty integer array as index it returns empty.

    wherecontains() has a return type as integer array even it's empty. so index will return empty.

    please check this snippet below.

    index({"A","B"},{},{"default"}) /*returns A,B */

    index({"A","B"},tointeger({}),{"default"})  /*returns empty */

Reply
  • Hi,

    One of the weird behaviours of index(), When you pass empty array as index it returns all values in the array because it treats the index as a list of empty nested field names (text).

    But if you pass empty integer array as index it returns empty.

    wherecontains() has a return type as integer array even it's empty. so index will return empty.

    please check this snippet below.

    index({"A","B"},{},{"default"}) /*returns A,B */

    index({"A","B"},tointeger({}),{"default"})  /*returns empty */

Children
No Data