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 / How to patch a text fi...
Power Apps
Answered

How to patch a text field to a choice column in Canvas Apps

(0) ShareShare
ReportReport
Posted on by 56

I am making a canvas app in which I have a text field , I want to patch the Value of the text field with a choice column in my dataverse table.

Mayank_Yadav_0-1713950479158.png

As you may see , I have a Gallery in which I have 3 buttons to show 3 options ["Morning" ,'Afternoon" ,"Evening"], whenever someone selects any of the 3 buttons it is highlighted in red and shown below in text in front of the "Preferred Time selected - " label.

 

For the Gallery items I have made a collection on the "OnStart" of the App like - 

ClearCollect(PreferredTime,{PreferredTime:"Morning"},{PreferredTime:"Afternoon"},{PreferredTime:"Evening"})
 
Now, I want to patch in the Dataverse table a choice column "Preferred Time" which has 3 choices {"Morning" ,'Afternoon" ,"Evening"}.
I can't seem to find the correct way to implement the above scenerio using the Patch function, 
Kindly Help, 
your Help will be highly Appreciated
Categories:
I have the same question (0)
  • VishalJhaveri Profile Picture
    1,169 Moderator on at

    Refer this master blog to achieve everything related to Patch functionality. Master CRUD Operations in Power Apps : Part 4 (inkeysolutions.com)

  • v-mengmli-msft Profile Picture
    Microsoft Employee on at

    Hi @Mayank_Yadav ,

     

    Do you want to patch "Morning" on the label to Choice column of Dataverse Table?

     

    Assuming that you want to create a new record in Dataverse table. Please try this.

    Patch(DataverseTable,Defaults(DataverseTable),{ChoiceColumn:Switch(Label.Text,"Morning",ChoiceTable.Morning,"Evening",ChoiceTable.Evening,"Afternoon",ChoiceTable.Afternoon)})//The ChoiceTable is the table used as choices of Choice column, you should replace it with yours table name.

     

     

    Best regards,

    Rimmon

  • Mayank_Yadav Profile Picture
    56 on at

    Hey Rimmon,

    Thanks for the Fast reply,

     

    I am not able to understand the patch command, Let me clarify for you,

     (1)-I want to create a new record in the "Appointment Table" whenever the user clicks on a Button to Patch a new record in the table,

    (2)- The Appointment table has a column called Preferred Time having 3 choices - [Morning,Afternoon,Evening]

    (3)- In my Canvas app I have the below scenario

    Mayank_Yadav_0-1713953375439.png

    in front of the Preferred Time label I have placed a Gallery, The items of the Gallery is the "PreferredTime" Collection that I have created on the 'OnStart' of the App using this formulae - ClearCollect(PreferredTime,{PreferredTime:"Morning"},{PreferredTime:"Afternoon"},{PreferredTime:"Evening"})

    --- The Gallery has 3 buttons whose placeholder Text is  - ThisItem.PreferredTime

    (4) - Below the gallery I have a label 'Preferred time selected' and In front of this label I have another lable named "SelectedTime" whose text property is - Gallery1.Selected.PreferredTime

     

    -- Now ,  what I want to patch in the Appointment table's Preferred Time Choice column to the value of the "SelectedTime" text label,

    I am making a Custom Page for further Clarification.

     

    Kindly Help,

    Thanks & Regards

  • Verified answer
    v-mengmli-msft Profile Picture
    Microsoft Employee on at

    Hi @Mayank_Yadav ,

     

    The formula in my first reply can archive what you want. If you don't know how to use Patch function, you can follow below steps.

    Step1.Add a button.

    Step2.Copy below formula to OnSelect of the button.

    Patch(YourDataverseTableName,Defaults(YourDataverseTableName),{ChoiceColumnName:Switch(Gallery1.Selected.PreferredTime,"Morning",ChoiceTable.Morning,"Evening",ChoiceTable.Evening,"Afternoon",ChoiceTable.Afternoon)})
    

     

    vmengmlimsft_0-1714014440229.png

     

    After finish above, you can click the button to check if a new record with selected Preferred Time has been created.

    Here is also a link about Patch function for your reference.

    Patch function (contains video) - Power Platform | Microsoft Learn

     

    _________________________________________________________________________________________________________________________

    If my answer helps you solve the problem, please accept it as a solution.😀

     

    Best regards,

    Rimmon

  • Mayank_Yadav Profile Picture
    56 on at

    Thanks Rimmon, was Able to implement it this time 👍

  • Mayank_Yadav Profile Picture
    56 on at

    Can you help with Another scenario that has been troubling me Mr.Rimmon

     

    I have a Combobox that I have copied from a form and using it in place of a default combobox that is provided in the tree view ,

    Mayank_Yadav_0-1714016965445.png

    I map the gender of the user in that combobox, I have renamed it as 'GenderDataCardValue3

    the items property of the combobox are - ["Male","Female","Other"]

     

    In the Appointment table I have a 'Gender' column that is a optionset and has values - ["Male","Female","Other"]

    I try to Patch it to the column like this

    Gender:GenderDataCardValue3.Selected.Value

    but it gives me this error - "The type of argument 'hil_gender' does not match the expected type 'OptionSetValue(Gender(Appointment))'. Found type 'Text'."

     

    Kindly help regarding this scenario

    Thanks & Regards

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 742

#2
Valantis Profile Picture

Valantis 474

#3
Haque Profile Picture

Haque 358

Last 30 days Overall leaderboard