cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Updatecontext variable from a gallery field after adding a record.

I have created an app that collects data stored in a Sharepoint list.  There are three screens.  One with a browse gallery, a detail screen and an edit screen. On the gallery screen there is a link to add records, a navigation control that links to the detail screen.  The detail screen has its item set to BrowseGallery.Selected.  There are three controls.  Back/Cancel, Edit, and Delete/Remove.  The edit screen serves and a new record input form or an edit form depending on which state is set on a context variable.  The problem I have is with adding multiple sequential record.  I set to context variables when the new record button is selected.  frmMode, and sHobbs.  The variable frmMode is set to 1 and sHobbs is set to a fldname of the gallery that represents a field of the dataset (list column).  The first record is added without issue, however, the subsequent records are being populated with the first value.  As an example record 1 sets the column value to the value assigned to sHobbs.  The app returns to the BrowseGallery screen and the last record is displayed in the BrowseGallery.  When the button to add another record is selected UpdateContext({sHobbs:fldEndHobbs}); Navigate(EditScreen1, ScreenTransition.None, {sHobbs:sHobbs, frmMode:frmMode}) is the onSelect formula.  Why is the sHobbs context variable not updating.  The contents of the variable seem to be null.  If I go to the edit screen and select edit then cancel the request the sHobbs is updated with the correct info.  Note that the edit button of the detail screen sets the sHobbs varible also, but, from a datacard value.

5 REPLIES 5
Highlighted
Helper V
Helper V

Re: Updatecontext variable from a gallery field after adding a record.

Can you please share some screenshots of this app?

Highlighted
Helper I
Helper I

Re: Updatecontext variable from a gallery field after adding a record.

addRecFormula.jpgNavDetail.jpgEditButton.jpginputFrm.jpg

Highlighted
Helper I
Helper I

Re: Updatecontext variable from a gallery field after adding a record.

I have posted the requested screen shots awaiting your response. 

Highlighted
Microsoft
Microsoft

Re: Updatecontext variable from a gallery field after adding a record.

Interesting. I don't notice any problems with what you've shared. Regardless, you could try creating global variables using the Set(variable, value) function instead of UpdateContext, which would probably simplify it a bit. Since Set() creates global variables, you don't need to pass them as a context to the screen through navigate, which will simplify that in case there are any problems there. 

 

Here's some documentation: https://powerapps.microsoft.com/en-us/tutorials/function-set/ 

 

I don't know if this will help, but this is what I'd try next.

Good luck!

- Paul C.
Software Engineer on PowerApps
Highlighted
Helper I
Helper I

Re: Updatecontext variable from a gallery field after adding a record.

I tried you suggesstion, but, I didn't work either.  The formula that sets the variable is only executed if another record is to be added.  The variable should be assigned the value of the newly added record from the gallery field that you can clearly see, however, the value being set is the previous sharepoint record.   The only way I have been able to get the variable to update is by navigating to the detail screen, then select the back button.  Then when the new record is added the proper value is assigned to the Start datacard of the input form.  Seems like a flaw in PowerApps.  Does the gallery field initially have a different reference than the one used to display the value?  I even tried to refresh the datasource onVisible before setting the global variable.  Still nothing.  There is definately an issue.

 

Ron

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (9,924)