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 a text fiel...
Power Apps
Answered

How to set a text field based on an If statement

(0) ShareShare
ReportReport
Posted on by 347

I need to set a text field approver in a form to be a persons email based on another field in the form.

The field is a choice field that it is checking.  There are 4 choices so it needs to be If then else if?

 

I was trying if(datacard11.selected.value = "MSS","person1"  then I got stuck since I need = "CMS"then on2" and if "JSS" then "person3" with default at end being "person 4"

Does anyone know the syntax?

I was putting in the default of the text field.

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dmclaughlin 

    You might want to consider the Switch function.  Something like this:

     

    Switch(datacard11.Selected.Value,
     "MSS", "person1",
     "CMS", "person2",
     "JSS", "person3",
     "person4"
    )

     

    That should give you what you need.

     

    I hope this it is helpful for you.

  • dmclaughlin Profile Picture
    347 on at

    I must have syntax alittle off

    Capture.JPG
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dmclaughlin 

    What is the Items property of that control?  If you are trying to set a Default, the default value must match the signature of the Items.

  • dmclaughlin Profile Picture
    347 on at

    I'm in the field called approver, it is a text field and I'm in the default property.  The field I'm testing is a different field, it is field order entry which happens to be datacardvalue11.  It is a sharepoint choice field and has 'MSS' as a choice.    

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dmclaughlin 

    Syntax looks good...what is the error you are getting?

  • dmclaughlin Profile Picture
    347 on at

    I've attached the definitions of the choice field  that I'm using to set the text field

    personapp field.JPG
    orderentrydb field.JPG
  • dmclaughlin Profile Picture
    347 on at

    Says invalid argument type(text), expecting boolean value instead

  • dmclaughlin Profile Picture
    347 on at

    attached  error

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dmclaughlin 

    Okay, the syntax in your screen shot is different than your first post about it.

    You have an equal sign in the one in the screenshot.

    The formula should be:

    Switch(DataCardValue11.Selected.Value, 
     "Indianapolis CMS", "Dmclaughlin@parker.com",
     "Houston CMS", "Dmclaughlin@parker.com",
     "Peoria CMS", "Dmclaughlin@parker.com",
     "MSS", "Dmclaughlin@parker.com"
    )

    In your screenshot, you have an equals after DataCardValue11.Selected.Value.

     

    Also, you might want to use line breaks in your formula to help you spot those issues quicker.  (a line break is Shift-Enter)

  • dmclaughlin Profile Picture
    347 on at

    Thank you!!!!!!!!!!!!

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 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard