cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Updating a field

Hi,

 

I'm struggling with the logic behind updating fields on power apps. 

 

I can get what I'm trying to do work when in the Edit Form but I want to make this work on the Detail screen.

I'm trying to update the status field to cancelled by using updateContext. 

 

Why isn't it letting me update the field in the details screen?

 

The button OnSelect is set to Update Context( { varStatus: "Cancelled"} )

A text input is set to varStatus

 

But then I'm not sure how to update this within the Details view.

 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Updating a field

Hi @globe11123 

The view form is designed to be read only.  That is why you are having problems trying to make it do something it isn't designed to do.  That being said, you can work around it by using the information that selected the record in the view form to patch the underlying datasource.  This is what @RandyHayes  is trying to tell you.  The syntax for this is

 

 

 

Patch(datasource, Lookup(datasource, ID = Gallery1.Selected.ID), {FieldToBeModified:"Approved"})

 

 

 

The datasource would be the one in your gallery.  The FieldToBeModifed,, likely Status, is the field name for Approved.  You may need to refresh the datasource after the patch for the change to be visible in your view form.  

View solution in original post

6 REPLIES 6
Highlighted
Super User III
Super User III

Re: Updating a field

@globe11123 

You mention that you are using UpdateContext and that is working in your Edit Form.

I am assuming that your Detail view is on another screen.

If that is the case then you need to realize that UpdateContext is a function to set local screen variables only.  If you need that variable to be global (across screens), then consider using a global variable instead:

Set(varStatus. "Cancelled")

 

Then you can reference the variable anywhere in your app.

 

I hope the assumption was correct and that this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
New Member

Re: Updating a field

@RandyHayes 

 

Cancel.PNG

I've updated the button code, on the Details Form which updates the text field that is set to varStatus.

 

But as you can see on the Status label it still says approved?

Highlighted
Super User III
Super User III

Re: Updating a field

@globe11123 

Did you actually change the formula on that field in your view form?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
New Member

Re: Updating a field

Which formula am I meant to change? 

 

This is where power apps is very confusing.

Highlighted
Super User III
Super User III

Re: Updating a field

Hi @globe11123 

The view form is designed to be read only.  That is why you are having problems trying to make it do something it isn't designed to do.  That being said, you can work around it by using the information that selected the record in the view form to patch the underlying datasource.  This is what @RandyHayes  is trying to tell you.  The syntax for this is

 

 

 

Patch(datasource, Lookup(datasource, ID = Gallery1.Selected.ID), {FieldToBeModified:"Approved"})

 

 

 

The datasource would be the one in your gallery.  The FieldToBeModifed,, likely Status, is the field name for Approved.  You may need to refresh the datasource after the patch for the change to be visible in your view form.  

View solution in original post

Highlighted
Super User III
Super User III

Re: Updating a field

@globe11123 

So for your view form, you'll want to unlock that data field and set the default to your variable.

That should show you the correct value.

Although keep in mind, this is display ONLY.  You will not be impacting the actual record, only the display of it.

As mentioned by @Drrickryp you'll want to implement a different formula if you want to impact the actual data.

 

Keep at it...the confusion will go away after a while!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,904)