cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MJ84
Helper I
Helper I

IF statement based context variable

Hi all,

 

I'm wondering if someone can help with IF statement being used based on a whether a context variable I have created = true.

 

So the context variable is button1:true and is set to the visible property.... So if I click a button another one shows and highlights a particular object this works fine.... I then have another button which I want to patch a specific record in a datasource which is displaying in a gallery if that context variable =true. The patch function works fine without the IF statement so this part I know is working ok.

 

The below is what I have but I'm not sure whether I have to reference the button itself or the variable - or both? 

 

If(button1=true,
Patch('Table1',ThisItem,{Desk1PM:Userlabel.Text}))

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
ganeshsanap
Memorable Member
Memorable Member

@MJ84 Try this:

 

1. On button click - OnSelect property of button, add below formula:

 

UpdateContext({ isButtonClicked: true })

 

2. On OnSelect of another button where you want to patch the item, use this formula:

 

If(isButtonClicked = true, Patch('Table1',ThisItem, { Desk1PM: Userlabel.Text } ))

 

For more information, check Patch & UpdateIf functions in Power Apps.


Please click Accept as solution & ‌‌👍 if my answer helped you to solve your issue. This will help others to find the correct solution easily. If the answer was useful in other ways, please consider giving it ‌‌👍

View solution in original post

2 REPLIES 2
ganeshsanap
Memorable Member
Memorable Member

@MJ84 Try this:

 

1. On button click - OnSelect property of button, add below formula:

 

UpdateContext({ isButtonClicked: true })

 

2. On OnSelect of another button where you want to patch the item, use this formula:

 

If(isButtonClicked = true, Patch('Table1',ThisItem, { Desk1PM: Userlabel.Text } ))

 

For more information, check Patch & UpdateIf functions in Power Apps.


Please click Accept as solution & ‌‌👍 if my answer helped you to solve your issue. This will help others to find the correct solution easily. If the answer was useful in other ways, please consider giving it ‌‌👍

@ganeshsanapperfect exactly what I needed thank you very much I really appreciate it.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,429)