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?
Solved! Go to Solution.
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.
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.
@Pstork1 Thank you! You're brilliant. You have no idea how much time I was spending on that problem
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.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
187 | |
52 | |
51 | |
36 | |
32 |
User | Count |
---|---|
284 | |
97 | |
89 | |
82 | |
77 |