cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AppDeveloper
Helper III
Helper III

Buttons Visibility: Whats wrong with my formula?

Hi

 

I have two buttons for 2 different approvers. I want to show one button to each and and then save approvers details in the form. These Admin users are coming from a SharePoint list. The problem is that this formula is displaying both buttons for both users which i don't want. There is something wrong in my following formula. Please notice the email1 and email2 which represents 2 different email addresses

If(Gallery.Selected.Status = "Submitted" Or "Partially Approved" And Lower(varAdminEmail) = Lower("email1@mycompany.com") ,true,false) 
&& MyForm.DisplayMode=DisplayMode.View

If(Gallery.Selected.Status = "Submitted" Or "Partially Approved" And Lower(varAdminEmail) = Lower("email2@mycompany.com") ,true,false)
&& MyForm.DisplayMode=DisplayMode.View 

 

 

&& Myform.DisplayMode=DisplayMode.view part is there to show this button only when it is in view mode as i am using the same form for editing, and new application.

 

To save the details of Approvers I am using this following formula

 

I simply check Status of Application either Submitted OR Partially Approved with this formula. This is working fine i am just mentioning as a reference here

 

If(MyGallery.Selected.Status = "Submitted",Patch(MyList,Gallery.Selected,{Status:"Partially Approved",'Approver 1': UserDetails.FullName}), Patch(MyList,Gallery.Selected,{Status:"Approved",'Approver 1': UserDetails.FullName}));ApproveButton1.Visible = false;

 

 

Kind Regards

1 ACCEPTED SOLUTION

Accepted Solutions

How are your conditions related, ie

 

(Cond_1 OR Cond_2) AND Cond_3

... or

Cond_1 OR (Cond_2 AND Cond_3)

 

Try including the wrapping brackets to match your requirements. 

 

Also, with your Lower() = Lower() test are you checking like for like data types, ie TEXT types. If you are testing say a TEXT type vs an Email type these tests can give incorrect results.

 

If these fail, you'll have to remove conditions one by one to find the offending one and try to figure out why it's not working

View solution in original post

9 REPLIES 9
AppDeveloper
Helper III
Helper III

I missed to mention that First 2 Formulas are on Visible property of the Buttons. Also if there is any better way to achieve please share.

 

Thanks

Eelman
Super User
Super User

@AppDeveloper 

You need to use this structure

 

If(

   Gallery.Selected.Status = "Submitted" Or

   Gallery.Selected.Status = "Partially Approved" And

   Lower(varAdminEmail) = Lower("email1@mycompany.com") ,

   true,

false)

Hi @Eelman   Thanks for your suggestion. I have already tried this option but the issue with this one is that It shows the button even by just entering into the FormScreen. That's why i used that last part 

&& MyForm.DisplayMode=DisplayMode.View

I checked when i Entered into my Screen  MyForm.DisplayMode = edit. I want to show this button only when admin clicks on an item in the gallery.

 

Regards

@AppDeveloper 

Try this instead

&& MyForm.DisplayMode="view"

@Eelman 

 

Thanks this part works fine. but i noticed that the following part is not working.

 

Lower(varAdminEmail) = Lower("email1@mycompany.com")

 

for example the email in varAdminEmail is different than email1@mycompany.com which results to False. still it is showing the button. This is very strange. it looks like as if the IF condition is not even reaching to And portion and quitting itself. Any idea Please

 

Regards

 

@AppDeveloper 

Can you please post the full code on just one of your buttons.

@Eelman 

 

after your suggestion above the current formula on button's Visible property is 

If(

   Gallery.Selected.Status = "Submitted" Or

   Gallery.Selected.Status = "Partially Approved" And

   Lower(varAdminEmail) = Lower("email1@mycompany.com"),

   true,

false) && CycleForm.DisplayMode ="view"

 

Once again Thanks for your time.

How are your conditions related, ie

 

(Cond_1 OR Cond_2) AND Cond_3

... or

Cond_1 OR (Cond_2 AND Cond_3)

 

Try including the wrapping brackets to match your requirements. 

 

Also, with your Lower() = Lower() test are you checking like for like data types, ie TEXT types. If you are testing say a TEXT type vs an Email type these tests can give incorrect results.

 

If these fail, you'll have to remove conditions one by one to find the offending one and try to figure out why it's not working

View solution in original post

Slaverty
Advocate III
Advocate III

Yeah, @Eelman has the right idea.  What your formula is essentially saying is

IF

Gallery.Selected.Status = "Submitted"   (Condition 1)

Or

"Partially Approved" And Lower(varAdminEmail) = Lower("email1@mycompany.com") (Condition 2)

true,

false

 

So if Gallery.Selected.Status = submitted for both buttons, you'll see both buttons, regardless of the email address of the user.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,168)