cancel
Showing results for 
Search instead for 
Did you mean: 

Patch - Referance a column name via a variable

Is that possible to make PowerApps can refer to a column via a variable?

 

I want to use "Patch" function to update column in Data Source. But the number of columns to be updated and columns name is not fixed. So it would be great of PowerApps to allow dynamically refer to a column.

 

 

For example, is it possible to replace the "DataField_8" below with dynamic variable such as "Dropdown2.Selected.Value"?

 

 
Patch(dbo_Update, LookUp(dbo_Update, ProductCode=Dropdown1.Selected.Value), {
    DataField_8 : TextInput1.Text
})
Status: Under Review

We hear you and appreciate your patience.  Unfortunately this is not easy for us to do.  Unlike VBA and other languages, Power Apps is strongly typed and named - everything is well established at compile time.  It's one of the fundamental principles of the product.  This allows us to detect more errors, optimize, and provide better intellisense during authoring.

 

Can you tell us more about the scenarios in which this would be helpful?  Some examples with code would be great.  Perhaps we can find a solution that addresses the need without making field names fully dynamic.

Comments
Frequent Visitor

This would be an extremely useful feature.  I've spent a full day trying to find a more efficient way to accomplish something and it turns out my 'hack' (massive Switch formula) is the best approach.  Especially frustrating as the referenced column structure in my app is somewhat fluid* so I have to update the formula every-time we add a column or consolidate columns.

 

*We are trying to normalize the various customer questionnaires our teams use (multiple redundancies and differences in term definitions) into a single SharePoint list.  The App allows users to select the form they want to use and it only displays the questions relevant to them (with answers pre-populated if someone already asked the question in a different forum).  Over time we plan to consolidate questions (columns) and add new questions (columns) as new requirements arise

Anonymous
Not applicable

Using dynamic column names will not violate you beautiful world defined by “Power Apps is strongly typed and named - everything is well established at compile time.” The reason is simple, column names are strings, so any variable of type string can be used as a column name. Simple to incorporate in PowerApps world. No?

Helper I

@GregLi 

 

In addition to dynamic patch functions, Having dynamic columns allows something so simple as a dynamic filtering interface for our data in our apps. 

A large majority of the "power apps" that are created for my organization are for small projects, including a BUNCH of "trackers" (tracking current status of various different processes within our company) These trackers often come with galleries full of table-layout data. I understand how to create switch statements that allow for this. They work fine, as long as our processes NEVER change (sometimes that may hold true. But in today's world, this is becoming less and less true) 

Realistically, processes change, and therefore, so do some of the options/statuses in our trackers. Not drastically, lets just add a new "Status" and call it "Returned For More Info" I would like to just add it to my list of dropdown options in my sharepoint list. and add "Return for more info" to the existing list of: "New","Accepted","Rejected"

Now, (because i populated a gallery Items with Choices(souce.status) ) My gallery instantly reflects this change! and now i have a new status i could potentially click on in my gallery to filter by (because before, if i click "New" it filtered for new, because that's in my switch statement, So I click on my dynamically generated "Return for more info" button, but my table breaks and i see absolutely no data. That's because the option "Returned for More Info" doesn't exist in my hard-coded switch statement. That's a poor breaking point. I have set up an almost entirely dynamic app that can handle dramatic changes without ever being needed to touch by a developer again. But Now my Sharepoint guys not only have to make changes to the sharepoint list to effect the app, but then i STILL have to open powerapps in dev mode and make changes to that switch statement, when i shouldn't have to. I should be able to update my sharepoint dropdown column options, and let it fully reflect and trickle through my app.