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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using variables in a p...
Power Apps
Answered

Using variables in a patch function

(0) ShareShare
ReportReport
Posted on by 363

Below is the setup for my variable. It is placed in the OnSelect of a combo box called "chsHorizRequire" drop down

 

Set(varHorizontalDatum,(If(
       chsHorizRequire.Selected.Value = "City Datum",
       "CityDatumDescr",
       If(
               chsHorizRequire.Selected.Value = "Previous Project Coordinates",
               "PreviousProjectCoordinatesDescr",
               If(
                      chsHorizRequire.Selected.Value = "Other",
                      "OtherHorizontalDatumDescr",
                      ""
               )
        )
)));

 

Below is my patch funciton

Patch(SurveyRequest_DB, Defaults(SurveyRequest_DB), { varHorizontalDatum: chsHorizRequire.Selected } )

 

Placing the "varHorizontalDatum" is throwing the error in the patch function.

Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    69,254 Most Valuable Professional on at

    You can't use a variable as a fieldname in a record.  The fieldnames need to be literal.

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Edit. Didn't realize you were making the field name a variable, like previous poster said that isn't possbile

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @colbyturybury If SurveyRequest_DB is the data source that u'r patching, where varHorizontalDatum is you need to replace it with the column that your patching. You can't have a variable. For example, if I'm patching an Employee List, the Patch would be, 

    Patch(Employee_DB, Defaults(Employee_DB), { Emp_ID: "1", Emp_Name:" John Doe", Emp_Title:"Director" } )

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard