Retrieving Gifts After Filtering a Custom Field

Help! I'm trying to create an automated workflow that will send me an email with a list of gifts if the value of a custom field in the gift is true. I was able to filter the custom fields, but that's where I start getting issues. I'm either stuck in the Apply to Each loop or disconnected from it. I feel like I'm missing a step somewhere…

Screenshot 2025-11-11 150244.png Screenshot 2025-11-11 150251.png Screenshot 2025-11-11 150302.png Screenshot 2025-11-11 150311.png

Best Answer

  • Stella Limuel
    edited November 12 Answer ✓

    I fiddled with it but now I'm still stuck with getting the list of filtered gift IDs for the Get a Gift to read.

    ETA: Figured it out!

    On the apply to each after "If no", I selected the appended Filtered Gifts variable. On the Gift ID of get a gift, I used item()['parent_id']. This pulls that specific item from the array.

    The Condition is length(outputs('Compose_2')) is equal to 0.

    Screenshot 2025-11-12 104806.png Screenshot 2025-11-12 104814.png Screenshot 2025-11-12 104825.png

Answers

  • Austen Brown
    Austen Brown Community All-Star
    Ninth Anniversary Kudos 5 PowerUp Challenge: Product Update Briefing Feedback Task 3 bbcon 2025 Attendee Badge

    Within your condition what does the 'Outputs' reference, are you trying to send an email if the custom field = true is present on a record? If so, I'd set your control up like this instead -

    Utilize the length() expression using the output of the Filter Array. Expression = length(body('Filter_array'))

    image.png

    Presume you only want to get one email, not an email for each instance found. Recommend moving the Create HTML Table to Email actions outside of the loop.

  • Stella Limuel
    edited November 11

    Thank you, @Austen Brown. That's where I'm stuck now, I can't get the gift ID of the filtered custom fields out of the loop for me to select as an output to get the gifts.

    I tried below but it gives me an error of "Unable to process template language expressions in action 'Compose_Gift_ID' inputs at line '0' and column '0': 'The template language function 'first' expects its parameter be an array or a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#first for usage details.'."

    Screenshot 2025-11-11 165739.png Screenshot 2025-11-11 165748.png
  • Austen Brown
    Austen Brown Community All-Star
    Ninth Anniversary Kudos 5 PowerUp Challenge: Product Update Briefing Feedback Task 3 bbcon 2025 Attendee Badge

    @Stella Limuel - Put a "get a gift" action above the control. Then use the gift ID output from that on the side of the control that you want to continue. You don't need to get the gift ID from the custom field directly. You just need the custom field to determine if you continue with the loop or not.

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary Kudos 5 Facilitator 3 Raiser's Edge NXT Fall 2025 Product Update Briefing Badge
    edited November 13

    What's the reason for get a gift? and even if you do have to get a gift, there's no need to get the "parent_id" from the list custom field to get the gift id, you already have this id, which is used to get the custom fields for the gift. That's said, from what I see your flow does, here's a breakdown of the actions:

    • List gifts
    • Apply to each 3 (apply to each gift from List gifts action)
      • List gift custom fields 2 (provide the ID field from the List gifts action)
      • Filter array (condition is likely correct, but can't tell if you selected the right value dynamic content, the correct one should be outputs('List_gift_custom_fields')?['body/value']
      • Compose 2 first(body('Filter_array'))?['parenti_id'] (this is not needed and is actually not correct logic, this expression is saying, give me the first matched gift custom field)
      • Condition
        LEFT: length(body('Filter_array'))
        is equal to
        RIGHT: 0
        • If yes
          • no actions needed, means the attribute you are filtering on doesn't exists on this gift
        • If no
          • Get a constituent (use the Constituent ID from the List gifts action)
          • Append to array variable 2 (this is where you will add the data you want into the array ready for making into HTML Table to include into Email)
    • Condition 2
      LEFT: length(variables('Email Content'))
      is greater than
      RIGHT: 0
      • If yes (means there are gift data added to the Email Content variable
        • Create HTML table
        • Compose
        • Send an email (V2) 2

    A few note to help you understand:

    • I used the same naming you are using, which basically is using naming given by Power Automate (i.e. Condition 2)
      • I strongly suggest you rename the action to make it more meaningful:
        Condition > Condition Filter Array Custom Field No Match
        Condition 2 > Condition Having Email Content
    • If I understand your intent correctly, you want to receive ONE email of all the gift that matches your criteria, not ONE email PER gift, this is why the Create HTML table, Compose, and Send an email (V2) 2 is taken outside of the Apply to each 3 loop
    • If any reason why you need the Gift a gift 2 action, the Gift ID field you can simply use the same ID field from the List gifts action that you used in the List gift custom fields 2 action
      • but I will say this again, you are unlikely going to need to add this additional action, the List gifts action provides the data you want to show in the email already