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
Highlighted
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

2 REPLIES 2
Highlighted
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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 172 members 5,720 guests
Please welcome our newest community members: