Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

PowerApp Question/Help Needed: Backloading values from gallery into form fields to edit

(1) ShareShare
ReportReport
Posted on by 42
Hello,
 
Needing help, screenshots included.
 
I have a form I am creating for Timesheets. When entering time worked, the user enters the project number, activity type, and hours for each day. These details and hours are loaded into a collection which displays below after the user selects Add Row. Then the fields empty (reset) themselves for a new row to be entered. However, I need the ability for users to edit existing entries as well. I would prefer that if they select the edit button (OnSelect) it loads that rows values (ThisItem.fieldName), back into the form control fields (3 drop downs, and 7 value fields) and then delete the item from the collection, so that it can be edited and re-added.
 
However, I cannot find a way so that when OnSelect is enacted the form fields are updated to the values of the ThisItem values.
 
CDN media

Showing Timesheet page, with arrows indicating the info that needs to be loaded back into form fields on select of edit button
 
CDN media
r/PowerApps - Showing OnSelect Attempt with Edit Button

Troubleshooting/Updates:
 
Following additional research, I read that a form field can only be controlled by using variables with Default values established representing those variables.
I have established a variable to test with, however it is not working to enable me to set one of the form fields (Project Number) to the value of ThisItem.ProjectNumber.
 
Variable: varNewTS_EditLineItem_PrjNumShort
 
CDN media
 
In the DefaultSelectedItems of the form field drop down for project number, I tried setting the default value to the variable when it is not blank.  I tried with [], with {}. and with [{}] without success.  While I have had other fields which accepted this functionality, of defaultSelectedItems, these (upon OnSelect of edit and in conjunction with the Reset function on the form field) would not load the value within the variable.  I did see however that the variable itsemf was being successfully loaded, as it's value would display the project number.  It just wouldn't load itself into the drop down field on reset it seemed.
 
CDN media
On Select of the edit button it successfully sets the variable to the ThisItem.ProjectNumberShort value.  The variable set would show the project value OnSelect of edit, however the form field would not change to populate with the value.

The variable loads OnSelect of the edit button. However, even though I use the reset function to attempt to reflect this value in the dropdown, it doesn't show up there.
Categories:
  • Verified answer
    PowerApp_Chaos Profile Picture
    42 on at
    PowerApp Question/Help Needed: Backloading values from gallery into form fields to edit
    UPDATE: I was able to get this working.
     
    On Edit I had to set the dd's DefaultSelectedItem to a table, relating to ThisItem, but pulling the table associated not with the gallery row but rather the table associated with the drop down box.  So, for project Number, I set it to the project number dropdown list table, filtered on the ThisItem.ProjectNumberShort.  
     
    This got it working.
     
    I also decided instead of backloading the items into the ADD ROW area, I would instead have them switch from labels to form controls within the gallery.  Then on clicking the SAVE icon it uses a patch function to reconcile the differences in that line.  
     
  • PowerApp_Chaos Profile Picture
    42 on at
    PowerApp Question/Help Needed: Backloading values from gallery into form fields to edit
    @FLMike, It is not a "form' in the traditional sense, as there is no form object on the page.  I used containers and controls to capture the info, and then they are added into the gallery at the bottom when Add Row is selected.  
     
    Must I use the actual form control, as shown below, in order to backfill values into form fields to edit.  Is there not a way to load values back into controls from a gallery otherwise onSelect of a button?
     
    I GREATLY appreciate your input regarding variable use.  I am relatively new with PowerApp development and learning best practices along the way.  I know enough about normalization of databases, but find myself lacking in front end development best practices.  Is there any reference material you could point me in the direction of that would further elaborate on your suggestion for variable management and development best practices?
     
    I think I understand you to be saying that fields or components of the pages should reference each other, rather than using global variables as the go-between.  Is the same true of loading data into global collections, which are essentially array/table variables from what it seems.
  • Suggested answer
    Michael E. Gernaey Profile Picture
    41,020 Super User 2025 Season 1 on at
    PowerApp Question/Help Needed: Backloading values from gallery into form fields to edit
    Hi
     
    Please show whats in the Item property of the Form. That is what you need to resolve. It won't change anything unless you make sure that that the thing you are editing is assigned in the item property of the Form.

    Also, using variables, especially on the same screen is not a good practice, whether they are global (like yours), or Contextual. It adds to the complexity, when you can directly access the values you need from the Form or the Gallery.Selected.

    It bloats your project and trust me, introducing lots of variables, DOES and WILL cause you issues as you forget to update them all the time, or properly, versus directly just getting the value you need from its control.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard