Adaptive Card use with table or array data

Options

I am working on my first NXT adaptive card and I am noticing when adding dynamic content the designer is automatically adding an “apply to each" step. I am guessing because this content returns multiple values from an array or table.

What is the best way to handle this situation, so I only return the value(s) I want in my json payload?

ie How could I pull the note summary for only one note type, or how could I only pull and display a subset of “consent options”

Thanks ahead of time for all the help.

Comments

  • Alex Wong
    Alex Wong ✭✭✭✭✭
    Ninth Anniversary Facilitator 4 Name Dropper Photogenic

    @Mark Zigadlo
    the important thing is understands data being returned by the action. You can use developer.blackbaud.com API Reference for the specific API call to understand.

    if the dynamic content you are trying to add is within an array/list of values, you will get Apply to each from flow automatically. The way to handle is to make a concious decision on if are you expecting always only ONE value or MANY values. Even after using the method below (Filter Array).

    after getting a list of notes for constituent, you can use “filter array” action to filter the notes by note type equals to the type you want. filter array will always return an array, since it cannot foresee if there will or will not be only ONE match based on your filter. So if you were to select dynamic content from the filter array action, flow will still put the action you are adding dynamic content from filter array into an apply to each. So the question is now more “business” related, are you expecting ONLY one note of the type you want, or are you expecting MANY. If you know there can ONLY be ONE, then you can use the first() expression to get the first item in the list of item. first() will intake the “body” of the filter array, and then specify the specific property you want. For example: first(body('Filter_Array_Action_Name'))?['summary']

    if you are going to access multiple properties of this filtered note, then you can use a Parse JSON with the first(body('Filter_Array_Action_Name')) as the Content. and provide the Schema using sample. this way, your subsequent action can use the dynamic content from the Parse JSON action without having flow putting apply to each automatically.

    If you expect there are MANY note that match, then you will need to determine how you want to display the multiple note's information (in a table, in a factset, or concatenated into a string), how you plan to display will affect how you will code to get the info.

Categories