Index() or dot notation?

Certified Lead Developer

Hi All,

I just wanted to know what's Appian best practices when it comes to retrieving data from a data subset. Should I index into the data subset or use dot notation? I noticed that when I use index() it doesn't throw an error for a null result set but does throws an error if I use dot notation. I know dot notation would cause a pink screen error on the tempo interface but debugging this would be quite simple since we know exactly where the error is coming from. For index(), this wont throw an error on tempo but will be harder to debug and would be a silent fail if a user doesn't raise the issue that that data is coming null when it shouldn't. 

  Discussion posts and replies are publicly visible

  • As per appian best practices, index() function should be used instead of dot notation. You can better handle the null conditions or other such as pink box error on wrapping with if condition to show some meaningful error messages to the end users.
  • The best practice is to use index function rather than dot notation.

  • As Naveen mentioned use index() function instead of dot data. In your query use if condition to show a appropriate error message to end user.
  • Certified Senior Developer
    The best practice would be use index() function instead of dot operator. we can check null condition for exception handling.
  • I agree that most of the time we want to use index to avoid any user-facing errors. However, in process models sometimes there could be benefits to using the dot notation. Let's say we have a data point that is required (100% of the time) in a non-time critical application and if for some reason it is null, we want it to throw an alert so that we would alerted and investigate the details further why this value is null. One could say you would still prefer to use index, but you would need to build in exception handling (& sending an e-mail?) into the process as well.
  • Certified Lead Developer
    I personally prefer to use property() to retrieve dot properties, and reserve index() for retrieving indexes (i.e. from an array) -- even though the two functions are functionally identical, i stress that it can help for comprehension, review, and troubleshooting purposes to have their uses segregated such.

    For instance, think of a time when you want to get a certain property from a certain index in an array... multiple-nested index() functions can get pretty hard to read pretty quickly.
  • Certified Senior Developer
    in reply to Mike Schmitt

    Hello Mike,

    I agree with your use of property(). I prefer to use property() when I am referencing a specific CDT field and index() when looking for specific indices.

  • I cannot think of a single reason why I would ever, ever want pink box error over some other functionality. Verbose errors, such as Appian likes to display in these cases, open up your whole architecture and design to malicious users who can use your error messages to find out how to crack your system.

    Users report error messages and often don't distinguish between them, which makes it hard to explain how these are separate issues and not the same one. You spend time fixing one pink box, and they tell you that you haven't showing you a completely different one, thinking it's the same thing.

    Using other methods allows you to try again, or go through a different process flow, or wait, or as they have stated display some meaningful information to the user, or do any number of things you could think of to allow process to continue. When you get a pink box, it comes do a dead halt and only sys admin or someone with designer privilege can get it going again.
  • When retrieving data from a CDT, use index(). When saving data into a CDT, use the dot notation.