cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KevHouston
Frequent Visitor

Setting a field's value based on a toggle selection

Within a SharePoint list form modified in PowerApps, I have a toggle, Toggle1.

 

I would like to set the value of a text field 'PWA', when the toggle field is False. 

 

How would I do this please?

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@KevHouston 
Create a variable to hold the value you want to set in the TextInput_PWA in the OnVisible property of the screen

Set(myDefaultValue, "")


Put this code in the OnUnCheck  property of the toggle

Set(myDefaultValue, "your text here")
Set(myResetDefault, true); Set(myResetDefault, false)

 

Then put this code in the Default property of the text input

myDefaultValue

 

And this code in the Reset property of the text input

myResetDefault

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

View solution in original post

3 REPLIES 3
mdevaney
Super User
Super User

@KevHouston 
Create a variable to hold the value you want to set in the TextInput_PWA in the OnVisible property of the screen

Set(myDefaultValue, "")


Put this code in the OnUnCheck  property of the toggle

Set(myDefaultValue, "your text here")
Set(myResetDefault, true); Set(myResetDefault, false)

 

Then put this code in the Default property of the text input

myDefaultValue

 

And this code in the Reset property of the text input

myResetDefault

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

Thanks for the response and details @mdevaney 


Having slight issues.

On the OnUncheck fx of the Toggle, I am entering as you listed;

Set(myDefaultValue, "your text here")
Set(myResetDefault, true); Set(myResetDefault, false)

KevHouston_0-1593006381752.png

 

 

Do I need to add a , or & or &&? Sure its simple on how the two lines act together, but cannot figure it out. It doesnt like with I add & or a comma.

Do I not need to declare the myResetDefault variable initially?

 

@KevHouston 

You need to separate the lines with ";"

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,133)