Selecting Donors from Query

Options

I'm trying to Select donors from a query instead of constituent lists. I'd successfully run this flow but it put my Custom Codes on some random records, so it isn't reading the Query I'm using. I experimented with a few different steps. My guesses have been wrong, so I'm putting it to the group.

8c7bea50eebe61c4d10a98c4e7544d7d-huge-st
9d8f77d61e782798208ae3b43ed8c14a-huge-st
ad98e9d4047d22869f4fe6b110e9fed7-huge-li

AttributefromQuery_20250424200134.zip

Comments

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Sean Pflueger
    I don't know what you mean by “put my custom codes on some random records”.

    from your screenshot, i can see you called “Start a query job” with a query id, then you did a “list constituents” follow by “apply to each” but I don't know what is in the apply to each.

    If you are trying to run query via query api, you are not doing it correctly. There are a few templates on how to use Query API in template showcase. Start there to understand how to use Query API first. In a nutshell.

    1. start a query job
    2. use dynamic content from #1 which is the JOB ID, get job status
    3. if job didn't finish yet, wait 30 seconds (or more) and get job status again
    4. when job status return sas_uri, which is the download link to the query job output, you can use it to download
    5. only after you download, you have access to the data of constituent to do what you want with them
  • @Alex Wong

    Are you saying I can't take the Ids of the constituents from the query and use an apply to each to apply a Custom Code? I don't need a download step. I'm trying to do pure automation.

    When I say I it applied Custom Codes to random Ids, I mean that the flow applied 500 Custom Fields and none of them were to any of the 28 records that were in my Query.

  • Austen Brown
    Austen Brown Community All-Star
    Ninth Anniversary 1,500 Likes 1000 Comments Name Dropper

    @Sean Pflueger - You can, but you need to follow Alex's steps 1-5 in his response – that will get you the output of your query to then use in the actual automation. It's one of those things that aligns with the motto of Power Automate - “it will take more steps than you think it should”.

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Sean Pflueger
    you have a big misunderstanding.

    Constituent List SKY API execute and download the list of constituent in ONE power automate flow action. You don't “realize” a download, but the action does it, without the download, you don't get any data to work with, no ID, nothing.

    Query API works differently, you request a query to be execute is only ONE action, then you need another action (in a loop) to check if the query execution is complete, then finally download the result in another action, from this last action is where you get the ID (and any other info you defined in the query execution).

    Once you have a list of ID (from List Constituent action or download query output action), you can then use apply to each ID and do something to it.

    I downloaded and import the flow zip file you included, inside your Apply to each, you have a create a constituent custom fields 2 action to create a constituent custom field for the constituent record identified by the ID field of the array returned downloaded" from the List constituents action. This should work to add the custom field each of the constituent in your List constituents action. The only thing is, the custom field you are trying to add (Donor Flow) is unique (meaning you can only have ONE per constituent) will fail if the constituent already have this custom field.

    Your statement “When I say it applied Custom Code (field) to random IDs…” does not make sense unless you made change to the flow that is different than what I saw in your zip file. You should look at the flow's run history (it sounds like you ran it once at least so you can check) and see what happen to the Create a constituent custom field 2 action inside the Apply to each, maybe post that to get additional help

    835768eebd2764bafe61af9ece52d03f-huge-im
  • @Austen Brown It takes more steps than you think it should. I hadn't heard that, but that is exactly what I'm thinking.

  • @Alex Wong Thank you! I'll work on these instructions this week.

Categories