How to save the result variable into a new variable after "For Each" loop?

Hi,
I am trying to get the response time from a dynamic table. I have to check the value every 3 minutes for a total of 5 times and for every run, I want to write the value to a text file.

Output example:
Response time for loop 1:
Response time for loop 2:
and so on…

Thank you for your help

Hi @aditi.sharma

You can declare 2 int variables countRun and TotalRuns
countRun=0
TotalRuns=5
Use a while loop countRun<TotalRuns
do
perform Tasks
delay 00:03:00
countRun=countRun+1
end loop

Assuming that the Response Time is being read from some place and then inserted in your text file.

If you wanna use it on a For Each loop use expression Enumerable.Range(0,5)

Thanks

Here’s an example workflow to achieve this:

  1. Initialize variables: Create two variables, loopCount (Integer) and responseTime (String), and set loopCount to 1.
  2. Start the loop: Use a “While” loop with the condition loopCount <= 5.
  3. Get the response time: Place the activities to retrieve the response time from the dynamic table or web page inside the loop.
  4. Write to text file: Use the “Append Line” activity to write the response time to a text file. Set the output text to "Response time for loop " + loopCount.ToString() + ": " + responseTime.
  5. Increment the loop count: Use an “Assign” activity to increment the loopCount variable by 1: loopCount = loopCount + 1.
  6. Add a delay: Use the “Delay” activity to wait for 3 minutes (180,000 milliseconds).

The response time is getting overwritten after every loop. I want to be able to save the value of each run and write that to my text file.

image

Hi @aditi.sharma

Give the count after the while Loop since while loop is insider for each loop every time it satisfies the while loop it goes to next activity increments and again performs the process under while loop. Hope it helps!!
Regards,

The output is still the same :frowning:

Hey @aditi.sharma

from where are you getting this response time?

Can you share the piece of workflow where this logic is written.

Thank you! I got it now. Made a small error

Can you mark the solution and close the topic.

Thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.