index() and property() function failure

Certified Associate Developer

Hello there,

I've used the index() and property() function for years to pull from CDTs and dictionaries however I've recently run into a problem where both functions are no longer working as expected.  Am I crazy here or is there something else going on?

I would expect both of the following statements to return "999" however, I am actually receiving "null" as the output.  

fn!index({startYear: 2022}, "YogiBear", "999")

fn!property({startYear: 2022}, "YogiBear", "999")

The screenshot below shows several varieties of the call, along with proof of dictionary format and content, returning null instead of the defaultValue from the index function.  I am able to reproduce this in 4 different environments including a cloud setup.

  Discussion posts and replies are publicly visible

Parents
  • This is actually documented functionality for the index() function.  When the data is a dictionary, the default is ignored and null is returned.

    Utilize a!map to obtain better results:

    fn!index(a!map(startYear: 2022), "YogiBear", "999")

    fn!index:

    Usage considerations

    The type of the default value must be same as that of the elements in the array.

    When the data is a dictionary, if the index is not found in the dictionary, the default will be ignored and a null value will be returned. Consider using a map instead of a dictionary.

Reply
  • This is actually documented functionality for the index() function.  When the data is a dictionary, the default is ignored and null is returned.

    Utilize a!map to obtain better results:

    fn!index(a!map(startYear: 2022), "YogiBear", "999")

    fn!index:

    Usage considerations

    The type of the default value must be same as that of the elements in the array.

    When the data is a dictionary, if the index is not found in the dictionary, the default will be ignored and a null value will be returned. Consider using a map instead of a dictionary.

Children