web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Updatecontext variable...
Power Apps
Unanswered

Updatecontext variable from a gallery field after adding a record.

(0) ShareShare
ReportReport
Posted on by 44

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.

Categories:
I have the same question (0)
  • Leo09 Profile Picture
    212 on at

    Can you please share some screenshots of this app?

  • roknron Profile Picture
    44 on at

    addRecFormula.jpgNavDetail.jpgEditButton.jpginputFrm.jpg

  • roknron Profile Picture
    44 on at

    I have posted the requested screen shots awaiting your response. 

  • Paul_C Profile Picture
    Microsoft Employee on at

    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!

  • roknron Profile Picture
    44 on at

    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

  • SP8 Profile Picture
    13 on at

    Have you tried setting the value OnChange? So that when the value changes it updates?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard