Power Automate help - Add fund desciption to Flow

Hi - I am being asked to add fund description to an email notification flow that sends an email to fundraisers when their assignees give a gift the previous day. I was able to initialize and create an array, but I can't seem to find/use it as an option to add to my email body. I don't know if it is related to it auto-generating an "Apply to each" section within an already existing "Apply to each" or if it is something else I did wrong. We don't use split gifts - so I really only need 1 fund per each gift.

I am pretty new to Power Automate and inherited this flow from a former co-worker. Including some screenshots of the current state of the flow that gave me an error. I tried pulling the Expression from a different flow that I found in the community: RENXT Large Gift Notification. However, I only get errors when I try to run it. Error:

ExpressionEvaluationFailed

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@items ('Process_each_gift')' is of type 'Object'. The result must be a valid array.

Any help would be great - thanks!

Best Answer

  • Alex Wong
    Alex Wong Community All-Star
    Tenth Anniversary Kudos 5 Facilitator 4 bbcon 2025 Attendee Badge
    Answer ✓

    since your org does not use split gift, there will be no situation where more than one fund for a gift, so here's what you can do in this order

    1. Add a Parse JSON action after Format gift amount for display
      1. Content: search for dynamic content "split" and select the Gift splits dynamic content under the list gift action with description under it that say The set of gift splits associated with the gift.
        image.png
      2. Content: put your type cursor in the Content text field, and do Ctrl-A to select all, then Ctrl-X to cut (copy and delete). open a Notepad and paste it there, it should look something like this: @{items('Apply_to_each')?['gift_splits']} (don't worry if yours does not say Apply_to_each, as it is likely another name for the loop that is looping each gift). What you want to do is add first() to it to have something like this @{first(items('Apply_to_each')?['gift_splits'])}. Then copy this whole thing and paste into the Content text field.
        image.png
      3. Schema: Paste this code
        {"type":"object","properties":{"id":{"type":"string"},"amount":{"type":"object","properties":{"value":{"type":"number"}}},"campaign_id":{"type":"string"},"fund_id":{"type":"string"},"appeal_id":{"type":"string"},"package_id":{"type":"string"},"gift_aid_amount":{},"gift_aid_qualification_status":{}}}
    2. Delete the Apply to each action that contains the Get a fund action
    3. Delete the action that initialize variable Fund
    4. Add Get a fund after the Parse JSON action and search "fund" from dynamic content and select the fund_id from the Parse JSON action.
      image.png
    5. You can use Description directly from the Get a fund action in your Send an email to the fundraisers action, replacing what you have there now that has the "join()" expression.
      image.png

Answers

  • Hi Alex - Thank you for responding so quickly! I had a little issue at step 1b with the updated Parse JSON formula as it was giving me an error saying it wasn't a valid JSON formula - but I was able to work through that and got the fund description to pull in. Thank you so much for your help!

  • @Kelsey Van Peursem I have a different way to do this. I pull in Get a Gift which loops around each gift in List Gifts. Get a Gift has the Fund ID in the Gift Splits which makes it easier than having to parse json. I created a string variable called Fund Description.

    image.png

    image.png

    For reference, the Gift Splits in the top is: outputs('Get_a_gift')?['body/gift_splits']

    In the Get a Fund is this field which will appear under Get a Gift.

    image.png

    Then Append to the string variable is the Fund Description which is under Get a Fund. Make sure to clear out your string variable at the end of the loop for each gift.

    image.png
  • @Carol Grant - Thank you for this alternate solution. I wonder if my issue was that my "get a fund" was retrieving data from the wrong section. Alex's solution is working, so I think I will be keeping it for this one, but I like the idea of not needing to use a Parse JSON on any future automations that might need this. I appreciate the alternate solution!
    Kelsey

Categories