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 🙂 

 

View solution in original post

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,501)