web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Continue Flow when Dataverse Table is empty

(2) ShareShare
ReportReport
Posted on by 422
Hi everyone,
 
I have a Power Automate Flow which completes an unbound action through the Dataverse Connector, to erase all records on a Dataverse table. This is working well (if anyone wants to see the methodology for this part, this video on YouTube was a big help).
 
I want the Flow to wait until there is confirmation that all records have been deleted from the Dataverse table before the Flow continues. I thought about using a 'Do Until' loop, with a 'List Rows' action, such that when there are no rows returned, the Flow can then continue. I'm looking for advice on whether this is the optimum way to achieve this or if there is a better way? 
 
If that's the best way, has anyone set this up before and if so, could you share the configuration for the 'Do Until', as I use these very rarely and am not very familiar with how to configure them. Does the 'List Rows' action fail when there are 0 rows returned from the table to list or would it be the case that it succeeds but an expression to check it's 'length' is 0? IE, what condition should I use in the 'Do Until'?
 
Many thanks for any pointers!
 
 
PS. No idea why you have to select a Category for these posts when all the selectable Categories are nothing to do with the question I'm asking. Sorry if this post ends up in the wrong place.
I have the same question (0)
  • Suggested answer
    developerAJ Profile Picture
    4,554 on at
    Continue Flow when Dataverse Table is empty

    I can think of two approaches:

     

    1) Custom table trigger

    Create a custom table, and at the end of your unbound process add an action that creates a new record in this table. That record will act as the trigger for a separate flow to perform the next steps.

    This is the preferred option, especially when the number of records is large.

     

    2) Do-while loop

    As you mentioned, you can use a do-while loop. Create a variable to store the number of records. Inside the loop, retrieve the record count and update the variable. For the loop condition, use ‘variable > 0’ so the loop repeats until the count reaches zero. Add a small delay inside the loop to avoid excessive execution.

  • pp365 Profile Picture
    422 on at
    Continue Flow when Dataverse Table is empty
    Thank you @developerAJ for your reply,
     
    Please can I ask for some more information on the first option. I am not sure why creating a new record in a custom table via the Flow following the unbound action would help. I don't think the Flow will "pause" itself while the Unbound Action fully executes and completes. In other words I don't think there is any feedback from the result of the Unbound Action to the Flow, so there is no 'built in' method of monitoring for the completion status of the Unbound Action. Therefore once it has executed the Unbound Action, I would assume it does not wait for completion and would simply move on to the next action, IE creating the record in the custom table.
     
    If that is the case then I am not sure that would be a reliable method of knowing the Unbound Action had completed. Please let me know if any clarification is required/if I have misunderstood your suggestion.
     
    For the second option, what would be the best method of retrieving the total record count from a Dataverse table inside a Power Automate flow?
     
    I read that this could be accomplished using the expression 'length(outputs('List_rows')?['body/value'])'. As all I would need is a count of the number of records, is this the best way? I then noted that there is a limit on the List Rows function of 512 records, expandable to 5,000 in the settings, and further to that via Pagination, but I don't want to exceed the API calls if all I need is a count of the records.
     
    Any further comments are much appreciated. It seems like a 'wasteful' approach to ask to retrieve tons of records just to get a count of how many records there are in a table.
     
    Many thanks again! 
  • Suggested answer
    abm abm Profile Picture
    32,770 Most Valuable Professional on at
    Continue Flow when Dataverse Table is empty
    Hi
     
    It all depends on how many records you need to delete. If you have only a few, you can use List Rows and delete each record in a loop, and the process will be synchronous. If you have a larger dataset, then an asynchronous approach is the best way to handle it.
     
    Also have a look on this api to get the status back from bulk delete operation
     
     
    GET /api/data/v9.2/bulkdeleteoperations(<BulkDeleteOperationId>)
     
    State code
     
    0 - Ready
    1 - Suspended
    2 - Canceled
    3 - In Progress
    4 - Completed
     
  • Suggested answer
    wolenberg_ Profile Picture
    985 Moderator on at
    Continue Flow when Dataverse Table is empty
    Hello @pp365
     
    You’re on the right track a Do Until loop with List Rows is the standard way to wait until a Dataverse table is empty before continuing.  
    How to configure it

    - Add a List Rows action inside your Do Until.  
    - Use an expression on the output to check the count of records:  
     
    length(body('List_rows')?['value'])
    
      
    - Set the Do Until condition to run until that length equals `0`.  
    - The  List Rows action does not fail when there are no records it simply returns an empty array, so the length expression will evaluate to 0.  
     
    Tips
    - Add a delay (e.g. 30–60 seconds) inside the loop to avoid hammering Dataverse with requests.  
    - Set a reasonable timeout on the Do Until to prevent infinite loops if something goes wrong.  
    - If you’re deleting a large volume of records, consider batching deletes and then checking emptiness at the end.  
     
    In short: use `length(body('List_rows')?['value']) = 0` as your Do Until condition. That way the flow will only continue once the table is truly empty.  
     
     
    If this helped or could help others in the community, feel free to give it a like or a kudo — it helps surface useful answers for everyone!
  • chiaraalina Profile Picture
    1,043 on at
    Continue Flow when Dataverse Table is empty
    Hi
     
    Since you asked for a example:
     
  • developerAJ Profile Picture
    4,554 on at
    Continue Flow when Dataverse Table is empty
     

    For the first approach I mentioned — instead of placing all the logic in the same flow as an outbound action — you can simply create a new record in the custom table at the end of outbound process and use that as the trigger for a separate flow. I believe I already mentioned the same in my original solution, so please read it again. If you can help me with your unbound process logic i can help better

     

    For the second approach, you don’t need to extend the default count. All you need to determine is whether the table is empty. Whether there are 10 records or 10,000 makes no difference — if even a single record exists, your flow should not proceed.

    I would even use top 1 to make the query run faster.

  • pp365 Profile Picture
    422 on at
    Continue Flow when Dataverse Table is empty
    @developerAJ , @chiaraalina , @wolenberg_ , @abm abm ,thank you so much for your fast and helpful responses, one of the best responses I've ever received from the Community!
     
    @abm_abm , as the number of records has the potential to be very large, I've gone with your suggestion of using the API to get the status from the BulkDeleteOperations process.
     
    I am almost there with achieving this, but am getting a very odd outcome which I'm hoping you might be able to help with. Just to clarify: the Dataverse Unbound Action for the BulkDeleteOperations is working fine, so the issue is not with that aspect, it is something to do with getting the outcome of the resulting system job via the API.
     
    I have set up the HTTP action in Power Automate, along with the relevant authentication (App Registration and API Permissions Assignment in Azure/Entra, Security Role assigned to the 'App User' in Power Platform Admin Centre).
     
    The call is working: when I did not insert a BulkDeleteOperationID in to the URI, it returned a very large number of BulkDeleteOperations records along with their status codes and IDs. However, when I try to insert the BulkDeleteOpertionID dynamically, from my Unbound Action - Bulk Delete action in the Flow, the Flow fails with the error "Entity 'bulkdeleteoperation' With Id = [redacted] Does Not Exist".
     
    I then copied one of the 'BulkDeleteOperation' IDs that Flow had returned before I tried to query for a specific run instance. It worked perfectly; 200 on the HTTP call and showed me the basic data about that single BulkDeleteRequest. I then tried another ID from this list, when the return of the operation didn't have a status code but was listed as 'null'; again this worked fine (so, the problem is not related to the BulkDeleteOperation not finding anything to delete).
     
    My next step was to wonder if it was simply a time lag between the BulkDeleteOperation submission, execution, and the ID being available to the Flow. I waited two hours and tried a dynamically produced ID; the Flow failed, indicating it's unlikely to be a lag-related issue. I have also tried using a 'Delay' between the Unbound Action and the HTTP action and this doesn't make a difference.
     
    I then tried to see if I could locate the ID of the BulkDeleteOperation in the System Jobs list (make.powerapps.com > Settings > Advanced Settings > System Jobs) so I could try manually inserting this in to the Flow. Although I see the BulkDeleteOperation listed I couldn't find a way to get the ID from the GUI. 
     
    I've also tried experimenting with the two different ID types I found from the output of the Unbound Action (BulkDeleteOperation) as I noticed it was sending an ID in the Header (REQ_ID and x-ms-service-request-id - the outputs of both of these seem to be identical), and returning an ID in the Body (JobID). Neither of these worked but I think it is 'JobID', in the body, that is the ID that's needed since this seemed to be the working ID when tyring one of the values it did return when I wasn't querying for a single ID on my first attempt.
     
    I've attached a screenshot to show the configuration of the action, but, I'm not sure this is where the problem is located as I've conducted quite thorough testing to show that the Flow and the HTTP action is working at the base level - the only failure [critical though it is!] is when I try to use the dynamic ID from the BulkDelete Unbound Action.
     
    I would be extremely grateful for any help on this. It honestly feels like this solution is 99% completed, there's just this one problem to solve. Thank you very much!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 489 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 257

Last 30 days Overall leaderboard