cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lord_Alexander
Regular Visitor

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
Anonymous
Not applicable

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 🙂 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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 🙂 

 

Thanks a lot!

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

 

Cheers,

Alex

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

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,280)