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 / How do I make sure tha...
Power Apps
Answered

How do I make sure that my code executes sequentially in Power Apps?

(0) ShareShare
ReportReport
Posted on by 42

I'm building a Power App that allows a user to take pictures using their smartphone camera and upload the image to a sharepoint list. To build the app I went to Insert > Media > Camera. The user simply user taps on the the live image in the app to take a picture. The tapping event triggers the OnSelect code for the Camera control, which is the following:

 

UpdateContext({showDialogBox: true});

 Collect(
 colImages,
 {
 DisplayName: ImageTextInput.Text & ".jpg",
 Id: ImageTextInput.Text & ".jpg",
 Value: Camera1.Photo
 }
 )

 

A dialogue box then opens with a field called ImageTextInput, then the user enters the desired name for the image. And here is where I have a problem: The Collect() code that you see above executes before UpdateContext() code, and therefore the image name ends up being blank. Why is that? How can I get UpdateContext() to execute first, so that it stores the user's desired name for the image BEFORE the Collect() code executes?

Categories:
  • Verified answer
    Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    Its not that the Collect code executes first.  The UpdateContext() executes first, then the Collect, then the app reacts to the change in the showDialogBox variable. I would move the Collect() function to whatever you are using to close the dialog box.  That way the order will be preserved. 

  • powaya Profile Picture
    42 on at

    @Pstork1 Thank you! You're brilliant. You have no idea how much time I was spending on that problem

  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    One of the keys to working with Power Apps that a lot of people have trouble understanding is that it is "Declarative" not "Procedural".  That's the root cause of what you are seeing.  You can't change properties of objects at runtime so you have to set a variable and let the object register the change.

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard