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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / When triggering deskto...
Power Automate
Answered

When triggering desktop flow from cloud flow, my variable does not increment

(0) ShareShare
ReportReport
Posted on by 4

I have a very simple desktop flow that runs a for loop and prints out a variable that I increment in the loop. When I run the flow on the desktop, it works perfectly printing out:

11/25/2022 5:06:24 PM: Start
11/25/2022 5:06:24 PM: Looping counter = 0
11/25/2022 5:06:24 PM: Looping counter = 1
11/25/2022 5:06:25 PM: Looping counter = 2
11/25/2022 5:06:25 PM: Looping counter = 3
11/25/2022 5:06:25 PM: Looping counter = 4
11/25/2022 5:06:25 PM: End Counter = 5

But if I run the exact same flow from a cloud flow, it prints out:

11/25/2022 5:08:44 PM: Start
11/25/2022 5:08:44 PM: Looping counter = 0
11/25/2022 5:08:44 PM: Looping counter = 0
11/25/2022 5:08:44 PM: Looping counter = 0
11/25/2022 5:08:44 PM: Looping counter = 0
11/25/2022 5:08:44 PM: Looping counter = 0
11/25/2022 5:08:44 PM: End Counter = 0

This is my script:

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
SET Counter TO 0
File.WriteText File: $'''C:\\Access\\LogFile.txt''' TextToWrite: $'''%CurrentDateTime%: Start''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode
LOOP LoopIndex FROM 1 TO 10 STEP 1
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
File.WriteText File: $'''C:\\Access\\LogFile.txt''' TextToWrite: $'''%CurrentDateTime%: Looping counter = %Counter%''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode
Variables.IncreaseVariable Value: Counter IncrementValue: 1
END
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
File.WriteText File: $'''C:\\Access\\LogFile.txt''' TextToWrite: $'''%CurrentDateTime%: End Counter = %Counter%''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode

 

Would appreciate some help.

TIA

Heinrich

I have the same question (0)
  • VJR Profile Picture
    7,635 on at

    I ran your code and it ran fine just like it happened to you. But I cannot run it from the cloud so it's really hard to say why that is happening in your case.

    Could you do some double checks about absolutely anything even the simplest thing.

    Maybe delete the Counter variable and try again. or Give it another name. or Print the LoopIndex instead of Counter. Or create an Input variable (instead of set variable) and use that and check.

     

  • Verified answer
    momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    Hi @HeinrichV 

    I have run your flow from Cloud (attended mode), and I got the correct results.

    I have made only one change to your code - added an input variable to indicate whether run was initialed locally or from the cloud.

     

    momlo_0-1669542118736.png

     

     

    27.11.2022 10:38:39: Start - Desktop
    27.11.2022 10:38:39: Looping counter = 0
    27.11.2022 10:38:39: Looping counter = 1
    27.11.2022 10:38:39: Looping counter = 2
    27.11.2022 10:38:39: Looping counter = 3
    27.11.2022 10:38:39: Looping counter = 4
    27.11.2022 10:38:40: Looping counter = 5
    27.11.2022 10:38:40: Looping counter = 6
    27.11.2022 10:38:40: Looping counter = 7
    27.11.2022 10:38:40: Looping counter = 8
    27.11.2022 10:38:40: Looping counter = 9
    27.11.2022 10:38:40: End Counter = 10
    
    27.11.2022 10:39:24: Start - Cloud
    27.11.2022 10:39:24: Looping counter = 0
    27.11.2022 10:39:24: Looping counter = 1
    27.11.2022 10:39:24: Looping counter = 2
    27.11.2022 10:39:24: Looping counter = 3
    27.11.2022 10:39:24: Looping counter = 4
    27.11.2022 10:39:24: Looping counter = 5
    27.11.2022 10:39:24: Looping counter = 6
    27.11.2022 10:39:24: Looping counter = 7
    27.11.2022 10:39:24: Looping counter = 8
    27.11.2022 10:39:24: Looping counter = 9
    27.11.2022 10:39:24: End Counter = 10

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 241 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 179

#3
Haque Profile Picture

Haque 159

Last 30 days Overall leaderboard