Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 3XyX3K4z/TrrottyNITLNy
Power Apps - Building Power Apps
Answered

Issues with Scope and timing

Like (1) ShareShare
ReportReport
Posted on 8 Feb 2025 02:28:41 by 16
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.
  • JasonD Profile Picture
    16 on 10 Feb 2025 at 21:33:08
    Issues with Scope and timing
    @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.
  • Pstork1 Profile Picture
    65,369 Most Valuable Professional on 10 Feb 2025 at 17:46:35
    Issues with Scope and timing
    @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
    16 on 10 Feb 2025 at 17:28:19
    Issues with Scope and timing
    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.
  • Verified answer
    Pstork1 Profile Picture
    65,369 Most Valuable Professional on 08 Feb 2025 at 14:08:01
    Issues with Scope and timing
    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
     
  • WarrenBelz Profile Picture
    146,508 Most Valuable Professional on 08 Feb 2025 at 09:00:41
    Issues with Scope and timing
    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.
  • Michael E. Gernaey Profile Picture
    35,752 Super User 2025 Season 1 on 08 Feb 2025 at 03:22:14
    Issues with Scope and timing
    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.

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

Thomas Rice – Community Spotlight

We are honored to recognize Thomas Rice as our March 2025 Community…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,508 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,369 Most Valuable Professional

Leaderboard
Loading started
Loading complete