Today I came across this post asking how to return multiple table values from a table lookup attribute with the use case being to dynamically build an email list for use with notifications’ dynamic email delivery endpoint. My first thought was table lookups can only return a single value, but then I thought, “well, let’s see if they actually work with the array data types.” Sure enough, I was able to return multiple lookup results to a string array! Read on for the details.

The table:

The attributes for the table lookup testing:

The table lookup configuration; to my surprise the Behavior Rule allows you to return an array of values when the attribute is set to an array type:

The resulting attribute value when Status = 1:

So now I had my array of values, but how to build the email list from this? Recently I was playing with Format function in the String Builder data reference and noticed it had the ability to handle arrays (function syntax like, Format(array, delimiter)), but I thought at the time, “what would you use that for?” Well now I know of at least one case! The final step here was to add a String Builder attribute called Email List and use it to convert the array above into a comma separated list:

As you can see from the Value field, we get exactly the list we want to plug into our notification dynamic email delivery endpoint!

I feel like this opens up some other possibilities to use table lookups and arrays so if you think of any interesting use cases, please post them in the comments below. And as always, thanks for your time!

Parents
  • I am also using the approach described above to return multiple values from a table lookup in an array attribute.

    My use case is to show these multiple values in the email body of a notification email.

    The problem that I am facing is I cannot find a way to show the array of multiple values vertically (each value in a new line) in the email body. No matter which new line control character I use as a separator, in the notification email body the values are displayed in the same text line (horizontally).

     

    Any ideas how I can display string or string array with multiple values each value in a new line in the pi notifications email body?

     

    Format('Array', NewLine()); already tested.

     

    Thanks,

Comment
  • I am also using the approach described above to return multiple values from a table lookup in an array attribute.

    My use case is to show these multiple values in the email body of a notification email.

    The problem that I am facing is I cannot find a way to show the array of multiple values vertically (each value in a new line) in the email body. No matter which new line control character I use as a separator, in the notification email body the values are displayed in the same text line (horizontally).

     

    Any ideas how I can display string or string array with multiple values each value in a new line in the pi notifications email body?

     

    Format('Array', NewLine()); already tested.

     

    Thanks,

Children
No Data