Skip to main content

Notifications

Community site session details

Community site session details

Session Id : hQqDd1+rSeCVoQHr+wftJJ
Power Apps - Building Power Apps
Answered

How to set a text field based on an If statement

Like (0) ShareShare
ReportReport
Posted on 16 Mar 2020 17:31:53 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.

  • dmclaughlin Profile Picture
    347 on 16 Mar 2020 at 18:34:12
    Re: How to set a text field based on an If statement

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

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 16 Mar 2020 at 18:27:35
    Re: How to set a text field based on an If statement

    @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 16 Mar 2020 at 18:21:02
    Re: How to set a text field based on an If statement

    attached  error

  • dmclaughlin Profile Picture
    347 on 16 Mar 2020 at 18:20:02
    Re: How to set a text field based on an If statement

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

  • dmclaughlin Profile Picture
    347 on 16 Mar 2020 at 18:17:51
    Re: How to set a text field based on an If statement

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

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 16 Mar 2020 at 18:17:47
    Re: How to set a text field based on an If statement

    @dmclaughlin 

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

  • dmclaughlin Profile Picture
    347 on 16 Mar 2020 at 18:14:51
    Re: How to set a text field based on an If statement

    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,287 Super User 2024 Season 1 on 16 Mar 2020 at 18:09:44
    Re: How to set a text field based on an If statement

    @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 16 Mar 2020 at 18:02:32
    Re: How to set a text field based on an If statement

    I must have syntax alittle off

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 16 Mar 2020 at 17:34:41
    Re: How to set a text field based on an If statement

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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 106 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 73

#3
stampcoin Profile Picture

stampcoin 52

Overall leaderboard
Loading started