cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lord_Alexander
Level: Powered On

Do 2 functions inside IF statement when it's true

Hello,

 

I have a problem with trying to make If statement do Patch and transition afterwards to different screen.

I have the following statement. It says Invalid Argument Type for Patch function part.

 

If(        !IsBlank(TextInput3.Text),  Patch(Table1_1, First(Filter(Table1_1, Bar_x0020_Code = TextInput3.Text)),
{Date: Today()}) && Navigate(Home,None), Label2.Text = "Required")

The moment I remove the && Navigate(Home,None) The function works and doesn't patch if Text is blank. 

If(        !IsBlank(TextInput3.Text),  Patch(Table1_1, First(Filter(Table1_1, Bar_x0020_Code = TextInput3.Text)),
{Date: Today()}), Label2.Text = "Required")

 

But Label2.Text = "Required" doesn't trigger when blank even though it doesn't Patch.

If I put IsBlank(TextInput3.Text) for second logical test

If(        !IsBlank(TextInput3.Text),  Patch(Table1_1, First(Filter(Table1_1, Bar_x0020_Code = TextInput3.Text)),
{Date: Today()}), IsBlank(TextInput3.Text), Label2.Text = "Required")

It doesn't work either when TextInput3 is blank.

 

Can anyone help me out why 2nd part doesn't trigger? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MelindaK
Level 8

Re: Do 2 functions inside IF statement when it's true

Hi,

 

First of all, you can chain multiple functions in a true case of an if by using ";" as delimiter. So your first formula will become:

If(        !IsBlank(TextInput3.Text),  Patch(Table1_1, First(Filter(Table1_1, Bar_x0020_Code = TextInput3.Text)),
{Date: Today()}); Navigate(Home,None), Label2.Text = "Required")


On the second part, with PowerApps you do not assign values to inputs/labels by direct assignment. You have to use context variables: https://powerapps.microsoft.com/en-us/tutorials/working-with-variables/

 

So, in your case instead of doing the direct assignment in case of false, you will update a context variable, which will then be used in the Text property of the label. Your formula will then be:

If(        !IsBlank(TextInput3.Text),  Patch(Table1_1, First(Filter(Table1_1, Bar_x0020_Code = TextInput3.Text)),
{Date: Today()}); Navigate(Home,None), UpdateContext({label2Text: "Required"})

- where label2Text is the name of the variable (you can name it anything)
Then on Label2 set the Text property to be label2Text.

 

Hope this helps 🙂 

 

MelindaK

View solution in original post

3 REPLIES 3
MelindaK
Level 8

Re: Do 2 functions inside IF statement when it's true

Hi,

 

First of all, you can chain multiple functions in a true case of an if by using ";" as delimiter. So your first formula will become:

If(        !IsBlank(TextInput3.Text),  Patch(Table1_1, First(Filter(Table1_1, Bar_x0020_Code = TextInput3.Text)),
{Date: Today()}); Navigate(Home,None), Label2.Text = "Required")


On the second part, with PowerApps you do not assign values to inputs/labels by direct assignment. You have to use context variables: https://powerapps.microsoft.com/en-us/tutorials/working-with-variables/

 

So, in your case instead of doing the direct assignment in case of false, you will update a context variable, which will then be used in the Text property of the label. Your formula will then be:

If(        !IsBlank(TextInput3.Text),  Patch(Table1_1, First(Filter(Table1_1, Bar_x0020_Code = TextInput3.Text)),
{Date: Today()}); Navigate(Home,None), UpdateContext({label2Text: "Required"})

- where label2Text is the name of the variable (you can name it anything)
Then on Label2 set the Text property to be label2Text.

 

Hope this helps 🙂 

 

MelindaK

View solution in original post

Lord_Alexander
Level: Powered On

Re: Do 2 functions inside IF statement when it's true

Thanks a lot!

Didn't know you can't update the text directly, only through a custom variable.

 

Cheers,

Alex

BO55VXR
Level: Powered On

Re: Do 2 functions inside IF statement when it's true

Wow ... i did not know this .. thanks.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,094)