Hello everyone,
I'm experiencing an issue with an "Until" loop in my Power Automate workflow that isn't functioning as expected. The loop is supposed to continue running as long as the hasMoreResults property in the API response is set to true. Here are the details:
Workflow Configuration:
I'm using an "Until" loop with the condition @equals(body('Copilot:_List_envelopes_1')['hasMoreResults'],true).
The loop has a limit of a maximum of 60 iterations or a maximum runtime of 1 hour (PT1H).
API Response:
The API response includes the property "hasMoreResults": true, indicating that there are more results available.
The response consistently provides only 10 records or envelopes, which are processed correctly.
Problem:
Despite the hasMoreResults: true property, the loop ends after one iteration and does not retrieve additional results.
I've verified that the condition is correctly implemented and the API response is as expected.
What I've Tried:
Reviewing the loop logic and API response structure.
Ensuring that pagination parameters are correctly used, if required.
Checking logs and debugging information to identify any potential errors or exceptions.
I would greatly appreciate any help or insights on how to resolve this issue. Are there specific pagination parameters I should be using, or are there other known issues with the "Until" loop in Power Automate?
Thank you in advance!
Power Automate Workflow Description:
This Power Automate workflow is designed to periodically retrieve completed envelopes from DocuSign and store the associated documents in a SharePoint Online site. The workflow is triggered every 30 minutes and operates within the "W. Europe Standard Time" timezone.
Workflow Components:
Trigger:
Recurrence: The workflow is triggered every 30 minutes, ensuring regular checks for new completed envelopes in DocuSign.
Actions:
Until Loop:
Condition: The loop continues as long as the hasMoreResults property in the API response from DocuSign is true.
Limit: The loop is constrained to a maximum of 60 iterations or a runtime of 1 hour (PT1H).
Copilot:_List_envelopes_1:
Type: ApiConnection
Function: Retrieves a list of completed envelopes from DocuSign using the /accounts/copilotAccount/envelopes/listEnvelopes endpoint.
Parameters: Filters envelopes by status (completed) and a specified from_date.
For_each_1:
Type: Foreach
Function: Iterates over each envelope returned by the Copilot:_List_envelopes_1 action.
Actions within Foreach:
Get_documents_from_an_envelope:
Type: ApiConnection
Function: Fetches documents from each envelope using the DocuSign API.
Path: Constructs the API path dynamically using the envelope ID.
Create_file:
Type: ApiConnection
Function: Uploads the retrieved documents to a specified folder in SharePoint Online.
Path: Specifies the SharePoint site and folder path for document storage.
File Naming: Names the file using the envelope title and the date sent, formatted as a timestamp.
Connections:
DocuSign: Utilizes a managed API connection to interact with DocuSign services.
SharePoint Online: Uses a managed API connection to store documents in SharePoint.
Parameters:
$connections: Defines the connection details for DocuSign and SharePoint Online, including connection IDs and names.
Overall Flow:
The workflow periodically checks for completed envelopes in DocuSign, processes each envelope to retrieve associated documents, and stores these documents in a designated SharePoint Online folder. The loop ensures that all available envelopes are processed, leveraging the hasMoreResults property to determine if additional pages of results need to be fetched.