cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Patch - Referance a column name via a variable

Hi,

 

I am trying to patch just the fields of a single colum, or a whole colum, to a datasource. The colum name can be anyone of 25 different names. I have tried to find a way to update the whole colum in one move, but i cant find a away that wil let me change the datasource when working with whole colums. I am using colums to sort the 500 records in the tables differently for each user.

 

So i am looking at a way to referance a colum name via a variable: I would like to be able to define the colum name via the 'ActiveSortTarget' but i cant get it to work.

 

Collect(UpdateChangesTemp,UpdateChanges);

ForAll(UpdateChanges, 
    Patch(If(LookUp(Hotel,NavnID = SelectHotel1.Selected.NavnID,Land = "France"),
          If(Slider1.Value = 1,'Vareliste Bar FR','Vareliste Koekken FR'),
          If(Slider1.Value= 1,'Vareliste Bar oe','Vareliste Koekken oe')),
    First(UpdateChangesTemp).RecordId,
    {ActiveSortTarget: Value(First(UpdateChangesTemp).ActiveSort)});
    Remove(UpdateChangesTemp,First(UpdateChangesTemp)));

Clear(UpdateChanges);

I can accomplish the task by wrapping it in a big Switch(), but was hoping for a simpler way.

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Patch - Referance a column name via a variable

Unfortunately this is not possible in PowerApps today - the name of the column used in patch requests cannot come from variables. You can consider creating a new feature request in the PowerApps Ideas board for this.

 

Regarding the Switch option, where you mentioned that you can "wrap it in a big switch" - that's currently the best way to do it, where you would have the switch call in the 'update' parameter of the Patch call.

 

View solution in original post

6 REPLIES 6
Highlighted
Power Apps
Power Apps

Re: Patch - Referance a column name via a variable

Unfortunately this is not possible in PowerApps today - the name of the column used in patch requests cannot come from variables. You can consider creating a new feature request in the PowerApps Ideas board for this.

 

Regarding the Switch option, where you mentioned that you can "wrap it in a big switch" - that's currently the best way to do it, where you would have the switch call in the 'update' parameter of the Patch call.

 

View solution in original post

Highlighted
Regular Visitor

Re: Patch - Referance a column name via a variable

Okay, Thanks for the help 🙂

Highlighted
Anonymous
Not applicable

Re: Patch - Referance a column name via a variable

Hi, @CarlosFigueira any update on the "column referencing"? Is it still not possible to refer to column via variable name till now (July 5th, 2018)?

 

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

 

Patch(dbo_Condoc_Nesta, LookUp(dbo_Condoc_Nesta, ProductCode=Dropdown5.Selected.Value), {
Condoc_DataField_8 : TextInput2.Text
})

 

Thank you in advance. 

Highlighted
Power Apps
Power Apps

Re: Patch - Referance a column name via a variable

This is still not supported; I believe you can use some sort of If function implement it, but you'll need to list all possible columns, something along the lines of the expression below, as suggested by the OP in this thread.

Patch(
    dbo_Condoc_Nesta,
    LookUp(dbo_Condoc_Nesta, ProductCode = Dropdown5.Selected.Value),
    Switch(
        Dropdown5.Selected.Value,
        "Condoc_DataField_8",
            { Condoc_DataField_8: TextInput2.Text },
        "Condoc_DataField_7",
            { Condoc_DataField_7: TextInput2.Text },
        "Condoc_DataField_6",
            { Condoc_DataField_6: TextInput2.Text }))

Please consider voting up for an existing idea on the ideas board, or creating one if it doesn't exist.

Highlighted
Anonymous
Not applicable

Re: Patch - Referance a column name via a variable

Thank you for your help. But in my case, the number of columns to be updated is not fixed so that I may not be able to use the "Switch" function.

Anw, thanks again for the update. 🙂

Highlighted
Frequent Visitor

Re: Patch - Referance a column name via a variable

Has there been any change to the use of Variables on selecting Columns on Patch function. This seems to be a major limitation if you want the user to select a Name (Row) and Column(Date) in order to update a specific attribute. I have tried referencing the DatePicker control in Patch but that does not work. So not sure how to get around giving the user the option to select and Name and Date to update a record. Seems this should be a basic feature...

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

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

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,329)