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 Apps / Issues with Scope and ...
Power Apps
Answered

Issues with Scope and timing

(1) ShareShare
ReportReport
Posted on by 50
I have a wizard that preps information where project managers describe new projects. Not all projects will have all potential components has parts of the new project.
 
The issue that I am running into is that it seems that the commands are not running sequentially.
 
The main list of actions is called from a manual button push that defaults all the context variables. There is a text field that is used as a log to show progress so that end users can follow along. Due to how objects are represented there is a need to use context variables as counters and since those cannot be updated inside ForAll loops I am having to put that code in buttons.
 
To the issue:
 
I have Documentation code being executed before Machine code. Meaning the code that builds the list of documentation we have to provide is run before the code that handles the machines that the documentation is about.
 
When I am looking at the log I see the header for the documentation being logged, then the header for the machine section, then some machines being logged and then the documentation.
 
Each non-header log entry is accompanied by a patch back to a table. The new records are added successfully but they are not in order of the code as it should be executed.
 
Is there a known issue with the main thread being executed first before Select calls are made to buttons and that code run? I would assume that this should be handled with a FIFO stack.
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,969 Moderator on at
    HI
     
    Sorry man/woman/person no way am I reading all these words, with zero code or pictures to show the problem and trying to figure it out. I'm a genius not a .. wait I am, but still no way.
     
    Help us help you.
  • WarrenBelz Profile Picture
    154,797 Most Valuable Professional on at
    I think what @FLMike is asking is that you post any relevant code in Text with an explanation of where and how you are using it and a summary of how the current outcome differs from that desired.
  • Verified answer
    Pstork1 Profile Picture
    69,127 Most Valuable Professional on at
    Power Apps is Declarative, not Procedural.  So Code that is in separate buttons is not guaranteed to run sequentially.  This is the way Power Apps is built. If you click a second button before the first finishes the code will not wait for the other button to finish.  This is particularly true of ForAll loops. They aren't really loops they apply the formula to all affected records simultaneously.  If the workload is the same the formulas will tend to finish in sequential order, but its not guaranteed.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • JasonD Profile Picture
    50 on at
    Thanks @Pstork1 for seeing that I was looking for help in understanding the platform and not needing help with code in particular. With the information that you gave I was able to confirm my suspicions and alter how I was doing things.
     
    Now I kick off the process to get the header patched and logged and all other subsequent sections of the process are in timers that will not start until certain criteria are met that mean that the prerequisite data has been transmitted to the system and can be verified.
  • Pstork1 Profile Picture
    69,127 Most Valuable Professional on at
    @JasonD, That approach should work. Normally, when I have time critical work I offload that to a Power Automate flow triggered from the app.  Power Automate is Sequential in terms of processing and won't do parallel processing unless you tell it to. The one issue with that approach is that it runs sequentially from Power Apps and has to return a result within about two minutes or the connection to the flow will time out.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • JasonD Profile Picture
    50 on at
    @Pstork1 In this job there are often new projects that are given on the last day of the month and they need to be entered ASAP. The wizard takes in the information, creates the deliverables and uses that deliverables list to create the lines that need to be entered on the sales order.
     
    There are lots of power automate flows that are associated with this project. In this case I did not want to have the user leave the interface and wait. I wanted them to see it complete in real-time as there are steps that they need to take immediately back in the main interface as soon as the wizard is completed.
     
    I am using flows for when notes are added or task statuses change and there are people subscribed to that project that need to know what changed.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard