Appending to Array
I am using the my Emma API to call a list of our subscribed email members. There are about 20,000 records. Emma returns 500 per page so I am trying to set up a loop to pull the records, parse them, append to an array, and then use that array to compare to RE NXT records to see if anyone that we have marked unsubscribed has re-subscribed. BUT it won't append. I have results in my parse JSON but it doesn't append anything to the array… Does anyone have any ideas?
Comments
-
@Liz DixonEversole
i'm assuming you are talking about Power Automate.While I don't know what Emma API is, Power Automate can handle 20K records in an array without issue. The question is, what are you doing to append. Is the “array” you talking about a “simple” array of only string (email address) or is it a “complex” array of object?
example of simple array of string ["abc@aol.com", “def@yahoo.com”]
example of complex array of object
[
{
"id": "131",
"address": "JPdiresta@net.com",
"constituent_id": "185",
"date_added": "1600-01-01T00:00:00Z",
"date_modified": "2016-10-19T19:42:38.775Z",
"do_not_email": false,
"inactive": false,
"primary": false,
"type": "Email"
}, {
"id": "135",
"address": "adiresta@aol.net.com",
"constituent_id": "333",
"date_added": "1600-01-01T00:00:00Z",
"date_modified": "2016-10-19T19:42:38.775Z",
"do_not_email": false,
"inactive": false,
"primary": false,
"type": "Email"
}
]You cannot append an array with different “type” of “item” (simple or complex)
so to better help you troubleshoot, you will need to provide a little more screenshots of the actions where you init the array, append to the array, the data you are trying to append.
0 -
@Alex Wong My bad! Yes. I am using Power Automate!
I am creating a variable called page which is an integer with a value of 1. A variable called allMembers which is an array with a value of []. A variable called hasMorePages which is a boolean with a value of true.
I then have a Do Until loop which runs until hasMorePages is false.
It called the Emma API, which returns a default of 500 rows. I am using the page variable in the call. concat('https://api.e2ma.net/ACCTID/subscriptions/SUBID/members?page=', string(variables('page')), '&page_size=500') This returns 500 rows.
I use a parse JSON to get a list of member_ids.
{
"type": "array",
"items": {
"type": "object",
"properties": {
"member_id": {
"type": "number"
}
},
"required": [
"member_id"
]
}
}
I have an Apply to Each which appends the body of the parse JSON to the allMembers array.I then have a condition outside the Apply to Each but inside the Do Until that looks at the body of the parse JSON and if it is less than 500 it sets the hasMorePages to false, otherwise it increments the page variable.
I have been able to make it work with just using the first 500 rows without all the loops and variables. But when I try to use the loops and variables, it doesn't seem to be adding anything to the array. When I test the flow, that section gets skipped…
I have remade it a thousand times using various logic and now I am just lost!
Any advice is appreciated!


0 -
@Liz DixonEversole
There is a logic error here. what you current have:- Do until hasMorePages = false
- HTTP get records based on page = variable page
- Parse JSON of the result from HTTP
- Apply to each (appears to be applying to each of the records returned)
- append to array variable allMembers with the records returned
- Condition on length of Parse JSON # of records < 500
- if yes
variable hasMorePages assign to false - if no
increment variable page
- if yes
The red above is wrong logic: what you want is to append all records from Parse JSON into the array variable allMembers; what you did though is to append all records from Parse JSON X times into the array variable allMembers; (meaning, if the first run has 500 records, you are appending the same 500 records, 500 times into the array variable allMembers.
Instead, the logic you want is:
- Do until hasMorePages = false
- HTTP get records based on page = variable page
- Parse JSON of the result from HTTP
- append to array variable allMembers with the records returned
- Condition on length of Parse JSON # of records < 500
- if yes
variable hasMorePages assign to false - if no
increment variable page
- if yes
Other note:
- click on Change limits in the Do until action, screenshot what is there
- the returned JSON (looking at your schema) is a complex array, even though you may think it is “simple” b/c it only has 1 number: member_id
- what may be better to do is use Data action Select to select the member_id from the array, which will create an simple array of number (i.e. [1, 2, 3, 4]), then append to array variable allMembers using the output from the Select action.
0 - Do until hasMorePages = false
-
@Alex Wong Thanks for this. Now I am running up against some sort of limit. I can get it to run for 5 pages--collecting a total of 2,500 records, but I have 13,000 records… Any chance you have any ideas? I've added a delay and tried changing it up from calling by page to calling by a start number, which makes it run longer (4 hours) and then it fails… UGH.
0 -
@Liz DixonEversole
shouldn't take this long. my guess is you still have unneeded loopscreenshot what you got now to get help
0 -
@Alex Wong For some reason it ends at 2499. I can call 2500 - 2999 in Postman, but cannot get it to work in Power Automate. The Do Until runs 5 loops, I added a second Do Until to call from 2500 - 4999 but it only runs one loop. Why?! Thanks for the help.




0 -
@Liz DixonEversole
your flow is too slow b/c of the Apply to each inside your Do Until loop. Your Apply to each is adding ONE of the 500 records at a time into the array. This is super slow.Instead, use union() expression to combine the array varible with the new array from HTTP and assign it back into the variable.

The Select action will select ONLY the member_id number from the Parse JSON. Then the Compose Combine Array uses union() expression to combine what was in the array with the new info from Parse JSON, and finally Set Variable of New Combined Array back into allMembers array variable.
union expression:
union(variables('allMembers'), body('Select'))
0 -
@Alex Wong Thank you! I will give this a try. In other news, for some inexplicable reason, I started running this flow last night and it actually processed through all 21 loops. SO WEIRD!!! But it does take time so speeding it up would be helpful. I will give this a try today.
0 -
@Liz DixonEversole
Do Until has 2 options as safe guard from an infiinity running loop:What is the MAX number of times the loop can run?
and/or
What is the MAX duration the loop can run?
By default, if you do not click “Change limits” to change it, the Count=60 and Timeout=PT1H means your do until will ONLY run for 60x max OR 1 hour, whichever comes first.
Only one of the option need to be specified, not both, so I suspect your flow ran over 1 hour and flow just “stops” the run.
Remove PT1H and your do until loop will run for a max of 60x. I do not recommend using Timeout as it leaves your flow logic up in the air as to what is done / not done. Use Count instead. Count specify the “max”, so it is not like the flow will definitely run 60x, if your logic only calls for the loop to run ~40x, then it will only run ~40x.
While this will fix your issue with flow not running all records pull, you don't want your flow to be running 1+ hour, implement what I replied earlier and your flow will finish in less than 10 minutes. (assuming what you said on OP, 20K records, 500 per pull, and per pull will take ~10 seconds, then the flow can finish in ~6-7 minutes, vs 1-2hr.
0 -
@Alex Wong You are a GENIUS!!!!!!! Thank you so much for your help.
I am embarrassed to type this… I think it was because I was running as a Test Flow. It was turned on and it ran itself at its scheduled time and it looped through 27 times! And my output contains the right number of records. I am going to die if this is the answer.
On an aside… After I make the array of all the member IDs, I get rows from a Google Sheet, I then do an Apply to Each for the Google Sheet results where I Filter Array to compare the MemberID (I just tried it converted to an integer, just in case it was a string) in the Google Sheet to the member_id (number) from the array. However, the filter array always returns a blank array… I added two Compose. And it is returning the right IDs and the right Array info (there are 107 no matches and 1 match) and I can see the values, but it always says the Filter Array output is [].
Any ideas?

0 -
@Liz DixonEversole
i'll need to see what your flow currently looks like to help. some screenshot in edit mode and run history will help understand the problemAlso, what exactly are you trying to do, it will be easier to suggest once I know what your intention for the flow is.
0 -
@Alex Wong I am trying to pull folks who belong to a subscription in our email provider (myEmma) and compare the member_id (integer) to the MemberID in a Google Sheet. Essentially, we have uploaded people to the subscription. When they unsubscribe, I am writing their information into the Google Sheet. That part works great. When they re-subscribe, I do not get an update or anything. They just go back into the pool of emailable folks for that subscription. So I am pulling anyone in that subscription and comparing them to the unsubscribes in the Google Sheet. If they match, I am deleting the row from the Google Sheet and adding it to a different Google Sheet. We are using the sheets to code the records in RE NXT and another system.
The Do Until to get the members from myEmma is working.

The Get Rows from Google is working.

But I cannot get the Apply to Each to work to filter both arrays.


I've tried it using the Google Sheet and the allMember array. I've tried converting the integers to strings, etc. Everything I do doesn't work. There is a match in there, but always filters the Array as a []. At this point, I can't remember what I have and haven't done and have so many versions, I am not even sure if I've sent the right screen shots

Is there a better way to do this comparison?
Thanks for the advice!
0 -
@Liz DixonEversole
it sounds like your google sheet has the unsubscribe, which is a lot less records than the emma list. so you are correct to “loop” (apply to each) through the google sheet returned rows.- Provide screenshot of your Compose action.
- provide a screenshot of the raw data returned by Get rows 2 and one of the Parse JSON inside your Do until loop
0 -
@Liz DixonEversole
there is another way to do this more efficiently using the intersection expression on the 2 array, but that requires both array to be “simple” array. The previous post asking for screenshot of raw data will help determine the path forward.0 -
@Alex Wong Thank you! I think I have it figured out. After making the array of records from Emma, I then made it into a Hash Set of objects. That seems to work! We are finally looping through all the records to find the matches. I will look into the intersection options though as I haven't used that before and it would be handy in other projects I'm sure. In the past, I've just filtered the array and then moved to a condition and it's worked, so who knew there would need to be more steps! I still need to go back and make the first array more efficient, but at least I have the parts working together so I can improve rather than focus on functionality. Thank you so much!!!!
0
Categories
- All Categories
- 6 Blackbaud Community Help
- 206 bbcon®
- 1.4K Blackbaud Altru®
- 394 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 357 Blackbaud eTapestry®
- 2.5K Blackbaud Financial Edge NXT®
- 646 Blackbaud Grantmaking™
- 561 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 934 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.4K Blackbaud Raiser's Edge NXT®
- 3.6K SKY Developer
- 242 ResearchPoint™
- 118 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 238 The Tap (Just for Fun)
- 33 Blackbaud Community Challenges
- 28 PowerUp Challenges
- 3 (Open) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 778 Community News
- 2.9K Jobs Board
- 53 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)
