cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jesper
Level: Powered On

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
PowerApps Staff CarlosFigueira
PowerApps Staff

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
PowerApps Staff CarlosFigueira
PowerApps Staff

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

Jesper
Level: Powered On

Re: Patch - Referance a column name via a variable

Okay, Thanks for the help 🙂

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. 

PowerApps Staff CarlosFigueira
PowerApps Staff

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.

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. 🙂

mike_lydick
Level: Powered On

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 161 members 5,658 guests
Please welcome our newest community members: