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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,765)