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 / Patch a choice field b...
Power Apps
Answered

Patch a choice field based on the toggle buttom

(0) ShareShare
ReportReport
Posted on by 7

Dear experts, 
I am newbie of programming, however i am so passioned with powerapps possibilities, 
and being inspired i decided to create some simple apps. 
Few words of the app I am currently developing: Inventory app for the chemical that are stored in my laboratory. 
I created a sharepoint list 'Inventory-chimica', that has some columns: 

1) some columns of Number type, where a number value is stored for the quantity and container type (e.g. 1 (KG) bottle x1 quantity). 
2) A choice column 'Luogo' for the place where the chemicals are stored: text strings, 3 option
3) A choice column 'Tipo' for the type of chemical, again text strings, e.g. "solvents", or "salts", "powders".
4) A problematic Choice type, 'Units', where has to be either the KG or L units, same text string. 
5) couple of other column that work as i expect. No sense to describe.

Current stage is: i build a page where the gallery is placed, another page where a selected item from gallery is displayed, and a page where the edit of the selected item is possible. 
A buttom with the possibility to add + new items, and a buttom to change current item. 
Title, Container type and its quantity input are simple "textinput" forms. In case of 'Luogo' and 'Tipo' i used a dropdown menu as an input form. And i want a toggle input form to determine the units of a newly created \ edited item. For e.g. "true" stands for the "L", and "False" for the "KG". 

 

Patch('Inventory-chimica';Defaults('Inventory-chimica');
{'Title 1':TextInput1.Text;
'Q.1':Value(TextInput2_3.Text);
'Cont. 1':Value(TextInput2.Text);
'Cont. 2':Value(TextInput2_1.Text);
'Q.2':Value(TextInput2_4.Text);
'Cont.3':Value(TextInput2_2.Text);
'Q.3':Value(TextInput2_5.Text);
Luogo:Dropdown1.SelectedText;
Tipo:Dropdown1_1.SelectedText;
Units:(Toggle1.Value=true; Value: "L")

})

 

 In the "falsetext" "truetext" options of the toggle i put the "KG" and "L" respectively. 
I tried to use the IF condition, that i didnt make to work either.
I also could use another dropdown menu to choose from, same as i did earlier, but i dont like it. 

p.s. i noticed, that some code that i found in internet uses "," as a separator, meanwhile my version of powerapps needs a ";" as a separator, is that okay ?

Thank you for any relevant help
And sorry if my question was discussed somewhere, 
i really did my best to find it

Screenshot 2022-10-24 at 09.35.31.png
Screenshot 2022-10-24 at 09.34.20.png
Categories:
I have the same question (0)
  • Verified answer
    victorcp Profile Picture
    2,350 Moderator on at

    Hi,

    The sharepoint choice column needs a record/object like this {Value: ""}, so to update you have to use the same schema. 

    in your case you can check if the toggle is true or false and use the truetext or false text repectively like this:

    Units:{Value: If(Toggle1.Value; Toggle1.TrueText; Toggle1.FalseText)}

     

     

  • Belenkiy Profile Picture
    7 on at

    Thank you, it worked smooth! 
    I expect it to be something similiar an easy solution
    appreciate your time 
    finally i can go further 

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 483

#2
WarrenBelz Profile Picture

WarrenBelz 399 Most Valuable Professional

#3
11manish Profile Picture

11manish 327

Last 30 days Overall leaderboard