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 set text variab...
Power Apps
Unanswered

How to set text variable value to an Optionset in PowerApp

(0) ShareShare
ReportReport
Posted on by 8

Dear All,

 

On an App i've used an OptionSet field which lists desired values during app execution. Further I have also used a AI Builder FormProcessor which reads a PDF document and provides me text values. I have stored the values retrieved in a variable. (Using UpdateContext function on the Onchange property of Formprocessor.)

 

Now i wish to set the retrieved value (avaialble in variable) to the optionset field. Any help would be great.

 

Regards,

 

 

 

 

Categories:
I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @niteshdambale ,

    Could you please share a bit more about your scenario?

    Do you want to set a text value back to a OptionSet type field in your CDS Entity from your app?

     

    If you want to set a text value back to a OptionSet type field in your CDS Entity from your app, I afraid that there is no way to achieve your needs in PowerApps currently.

    The 'Option Set' field in CDS Entity is required to provide Option Set type value only, you could not assign a Text value back to Option Set field.

     

    As an alternative solution, I think the If function could achieve your needs. You could consider patch corresponding Option Set option value back to the Option Set field based on the Text variable value.

    I assume that you want to use Patch function to patch data back to the Option Set field, please take a try with the following formula:

    Patch(
     'CDSEntity',
     Defaults('CDSEntity'),
     {
     ...,
     OptionSetColumn: If(
     TextVariable = "value1", /* <-- TextVariable represents the text variable that you set using UpdateContext function */
     OptionSetName.Option1, /* <-- OptionSetName represents the name of your Option Set type, which binds to your OptionSetColumn*/
     TextVariable = "value2",
     OptionSetName.Option2,
     TextVariable = "value3",
     OptionSetName.Option3,
     ...
     )
     }
    )

    If you use Edit form to submit your data, please set the Update property of the Option Set field data card in your Edit form to following:

    If(
     TextVariable = "value1", /* <-- TextVariable represents the text variable that you set using UpdateContext function */
     OptionSetName.Option1, /* <-- OptionSetName represents the name of your Option Set type, which binds to your OptionSetColumn*/
     TextVariable = "value2",
     OptionSetName.Option2,
     TextVariable = "value3",
     OptionSetName.Option3,
     ...
    )

    Please consider take a try with above alternative solution, then check if the issue is solved.

     

    Best regards,

  • niteshdambale Profile Picture
    8 on at

    Hi @v-xida-msft,

     

    Thanks for your reply.

     

    Here's bit more information as requested :

     

    1) Using Patch Function I am able to patch the CDS entity --> Optionset fields sucessfully. The sample function is pasted below for your reference

     

    Capture.PNG

     

     

     

     

     

     

     

     

     

    (1) Here "Title" & "Gender" are Optionset fields in CDS entity

    (2) Nationality is a Lookup field in CDS entity.

    (3) Filter "First"is used to search and drill down to exact record which is to be updated

     

    Now the query is as follows :

     

    I have a powerapp which uses form processor to read PDF document. On change event of the form processor i have captured all values in variables. Example :

     

    Capture.PNG

     

    Here title, gender & nationality are my varaibles. I am sucessfully able to store the value of form processor fields into variables.

    Now on the power app formscreen i have placed three fields mentioned above.

     

    Capture.PNG

     

    My query is, i wish to set the Values present in variables to the Optionset and Lookup fields on the form. E.g. Variable Gender Provides me text "Female". I have an optionset name "Female" with value 10000001.

     

    Is this possible ?

     

    Hello @HSheild your help would be appreciated..

     

     

    Regards,

     

    Nitesh

  • SristiJain Profile Picture
    13 on at

    Hey! What if I am not using any Option Set, like I have declared my option set values. What should I use in place of 

    OptionSetName.Option1

    then?

    Thanks! 

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!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 85

#2
WarrenBelz Profile Picture

WarrenBelz 76 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 38 Super User 2026 Season 1

Last 30 days Overall leaderboard