Payments BBPS Transaction ID

Options

I'm trying to add the BBMS transaction ID, which is included automatically by Online Express, to gifts received via web view donation and registration forms.

However, every time I try to add it, the Apply to Each control starts nesting itself very strangely, and the flow does not work, giving me an error of “The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each')' is of type 'Object'. The result must be a valid array.” This is despite PA choosing the field as “current item” itself.

This odd nesting ONLY happens when I add they dynamic content field Payments BBPS Transaction ID. Other fields do not cause this issue. Does anyone have an idea why and/or a work around?

TYVM!

Comments

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary Kudos 5 PowerUp Challenge #3 Gift Management Name Dropper

    @Emmet OConlon
    The error message seems to be good indicator that the “dynamic content” used is not an array. Apply to each can only accept an array to “loop” through each element of an array.

    Power Automate is pretty good at “placing” the correct array dynamic content, so there got to be something with the way you are adding action and dynamic content to those action. Hard to help you investigate without some more info. Please provide additional screen shots

  • @Alex Wong Here is what it looks like before I add the Payments BBPS Transaction ID:

    c0cdf85a245a2e8600bad9d7efc74137-huge-pa

    I consider this “normal.” Now, look what happens to the structure after I add that particular field:

    66c1c66fe7400a3a8b88f048af0c24fe-huge-pa

    I've tried changing out the “Current item” in the second Apply to Each to “value," but that yields PA to try to add the attribute at least twice in some sort of weird loop.


  • @Alex Wong I've found a solution, but I'm not sure why it works.

    I used Get Gift after the Apply to Each step to successfully get the BBMS transaction ID (called bbps_transaction_id) in a variable. After that, I was able to update the transaction ID successfully.

    Screenshot of revised flow below.

    380b4ba6747b214af800505caa50136a-huge-pa


  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary Kudos 5 PowerUp Challenge #3 Gift Management Name Dropper

    @Emmet OConlon
    Glad you got this working for you.

    So if you want to dive into the details on how and why, here it is, and some tip on simplifying the flow:

    • After your List gifts action, you actually do not need to do a Condition action as the condition is simply if Count is greater than 0
      • The Apply to each action will loop through the gifts in your List gifts action, so if there is nothing (Count = 0) the Apply to each will simply exit and not execute any actions within it
    • The problem you encountered is a “gitchiness" of Power Automate flow, I can't explain why, but here's the reason for the failing:
      • if you look at the API documentation for List Gift (https://developer.sky.blackbaud.com/docs/services/58bdd5edd7dcde06046081d6/operations/ListGifts), go down to the Response 200 OK section and click on Schema, do a browser find on “bbps”, you will find that bbps_configuration_id and bbps_transaction_id is a String property inside payments. payments is an array itself.
      • because payments is an array, when you reference the bbps_transaction_id property, flow will put another Apply to each that loops through the payments array. This is where flow failed, and put the wrong dynamic content for you that caused the error you saw.
      • To do this properly, you can simply add a Apply to each action yoursevles (don't let flow do it). Then in the * Select an output from previous steps, select the Payments dynamic content (the one that has desscription that say “The payments on the gifts”)
    fed45d454ead9f769d1b408ecc585ddb-huge-im

    If you want to go a little more “clean”, KNOWING that there really is ONLY ONE payment object in the Payments dynamic content array, you can use the first() expression to get the first payment object in the array, and get the bbps_transaction_id off the first payment object.

    071ee608c855e0c4ebe5f9155d1aec12-huge-im
    @{first(items('Apply_to_each_gift_from_List_gifts')?['payments'])?['bbps_transaction_id']}

Categories