I have to create a loop for 20 mins , where to change the regions and it should be stopped once its reached 20 mins

I need to create a loop for 20 minutes, the regions are present in array ,where I want to change regions every 20 minutes in the loop. The loop should continue to switch to another region after completing the first one, and it should stop once it has reached a total of 20 minutes.

And if there is no data in first region then it should stop the loop and pick second region.

@gupta_sai ,

Please take a look and try

To create a loop in UiPath that iterates through an array of regions every 20 minutes and stops if there’s no data in the current region, you can use the following approach. Below is a step-by-step guide for implementing this:

Step 1: Define Your Variables

  1. Regions Array: Create an array of strings to hold your regions.
  2. Current Region: Use a string variable to hold the current region.
  3. Data Exists: Create a Boolean variable to check if data exists in the current region.
  4. Current Time: Create a variable to track the elapsed time.

Step 2: Build the Workflow

  1. Initialize Variables:

    • Create an array of regions. For example: regionsArray = {"Region1", "Region2", "Region3", ...}.
    • Initialize a counter for the total elapsed time (in minutes).
  2. Use a While Loop:

    • Create a loop that will continue while the total time is less than or equal to 20 minutes.
  3. For Each Region:

    • Use a For Each activity to iterate over your regions.
    • Inside the loop, set the Current Region to the current item in the loop.
    • Use an activity to check if there is data in the Current Region (this could be a custom logic or service call).
  4. Check Data Availability:

    • If there is data, execute your desired activities.
    • If there is no data, use the Break activity to exit the For Each loop.
  5. Add a Delay:

    • Use a Delay activity to wait for 20 minutes (set the duration to 00:20:00).
  6. Update Total Time:

    • After the delay, update your current time counter to reflect the elapsed time.

Sample Workflow Structure:

Below is a simplified representation of what your workflow would look like:

  1. Initialize Variables:

    - regionsArray = {"Region1", "Region2", "Region3"}
    - totalElapsedTime = 0
    - regionDuration = 20 // in minutes
    
  2. While (totalElapsedTime < 20):

    • For Each currentRegion in regionsArray:
      • Check if Data Exists in currentRegion:
        • If DataExists == true:
          • Execute activities for currentRegion
          • Delay for 20 minutes
          • Update totalElapsedTime by 20
        • Else:
          • Break the loop

Example Code Snippet:

' Pseudocode/structure to guide your UiPath implementation
regionsArray = {"Region1", "Region2", "Region3"}
totalElapsedTime = 0
regionDuration = 20 // in minutes

While totalElapsedTime < 20
    For Each currentRegion in regionsArray
        DataExists = CheckDataInRegion(currentRegion) ' Custom method to check data
        If DataExists Then
            ' Perform activities for the current region
            Delay("00:20:00") ' Wait for 20 minutes
            totalElapsedTime += regionDuration
        Else
            Break
        End If
    Next
End While

Important Notes:

  • Make sure to replace CheckDataInRegion(currentRegion) with your specific logic for determining if data exists in a region.
  • Ensure that all activities you plan to execute while working with data are implemented within the respective checks.
  • Always remember to handle exceptions and edge cases to ensure the workflow runs smoothly.

@Yoichi @Gokul001

Could give good idea to implement the good logic in it

@gupta_sai,

As you already have the regions in an array, just use For Each activity and pass array variable to iterate.

Inside the For Each after your region changing logic, use Delay activity with Timespan of 20 minutes.

The image shows a "For Each" loop configuration in a workflow, which processes each "region" in the "arrRegion" list, with a subsequent delay of 20 minutes after executing the logic to change the region. (Captioned by AI)

Thanks,
Ashok :slight_smile:

Hi,

If I understand your requirement correctly, either of the following will work.

If you need to exit the loop In a coercive manner when 20 min is elapsed, timeout property of InvokeWorkflow will help you. Please write workflow for the loop in another file.

Note: It may be necessary to turn on Isolate option in the InvokeWorkFlowFile activity.

If you need to exit the loop In a graceful manner (this means loop will exit at safe check point) when 20 min is elapsed, the following StopWatch class will help you.

Regards,