Skip to main content
July 13, 2021
Question

Property Function - default value return Null

  • July 13, 2021
  • 8 replies
  • 0 views

i am trying index the property "ISOCountryCodeOfIssue", if it is not available in the dictionary (data). We need to default value output.

We run the expression , it return back null instead of "BCD"

property(
{
/*ISOCountryCodeOfIssue: "ABC",*/
expiryDate: "10/20/2016",
issueDate: "10/20/2011",
documentId: "XR58",
documentType: "PASSPORT",
issuingAuthority: "EN"
}
,"ISOCountryCodeOfIssue","BCD")
Not sure what am i exactly missing here

8 replies

csteward
July 13, 2021

Strangely enough I can't say I've run into this "feature" with property() over a dictionary object..  I receive the same result of null vs "BCD" in my environment however.  Barring the unexpected functionality there, a few options are, use a!map() if you are on a recent version of Appian, or convert to a datasubset:

property(
  a!map(
    /*ISOCountryCodeOfIssue: "ABC",*/
    expiryDate: "10/20/2016",
    issueDate: "10/20/2011",
    documentId: "XR58",
    documentType: "PASSPORT",
    issuingAuthority: "EN"
  ),
  "ISOCountryCodeOfIssue",
  "BCD"
)

property(
  todatasubset(
    {
      /*ISOCountryCodeOfIssue: "ABC",*/
      expiryDate: "10/20/2016",
      issueDate: "10/20/2011",
      documentId: "XR58",
      documentType: "PASSPORT",
      issuingAuthority: "EN"
    },
    a!pagingInfo(1,1)
  ),
  "ISOCountryCodeOfIssue",
  "BCD"
)

davel001150
July 13, 2021

Hate to say it, because it's such anathema to myself and Mike Schmidt, as we've had many discussions on the subject before, but if all else fails you could see how the index() function behaves getting your property.

BTW, SUPER EXCITED to see someone on the forum actually starting with property() to get a property!  But if it has a failing, then I suppose I can extend more grace to all who use index() for everything.

csteward
July 13, 2021
SUPER EXCITED to see someone on the forum actually starting with property() to get a property!

Amen!  Combined with INSERT -> CODE would have iced the cake :)

Also to note, index() also provides the same NULL return, which is not what I would expect..

index(
  {
    /*ISOCountryCodeOfIssue: "ABC",*/
    expiryDate: "10/20/2016",
    issueDate: "10/20/2011",
    documentId: "XR58",
    documentType: "PASSPORT",
    issuingAuthority: "EN"
  },
  "ISOCountryCodeOfIssue",
  "BCD"
)

alex.ladue
July 15, 2021

Unfortunately there is a bug with index/property that cannot be fixed due to our backwards compatibility guarantees. If you attempt to index into a field that does not exist on a dictionary, it will always return null instead of the defined default value.This should only apply to the dictionary data type, so consider using a!map() instead. This will be added to the documentation soon.