web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / If condition in the vi...
Power Apps
Suggested Answer

If condition in the visible property

(2) ShareShare
ReportReport
Posted on by 119
Dear all,
 
could you please advise what is wrong in my formula below?
 
I am trying to restrict user from editing a form by hiding the "Edit" icon (pencil) that changes display mode of the form from View to Edit.
 
What I want to achieve is that the person "Created by" is only able to see the pencil icon in statuses "Draft", "Declined by Accounting", "Declined by Manager", "Declined by CFO". Also the pencil icon should only be visible in display mode View. When the display mode changes to Edit, the pencil icon should not be visible.
 
The form is showing item selected from Gallery_Expenses in default view mode, but the pencil icon changes the mode to Edit.
 
Thank you in advance.
 
If(
    'Form_View/Edit'.DisplayMode = DisplayMode.View && Gallery_Expenses.Selected.Status.Value = "Draft" || "Declined by Accounting" || "Declined by Manager" || "Declined by CFO" && User().Email = Gallery_Expenses.Selected.'Created By'.Email,
    true,
    If(
        'Form_View/Edit'.DisplayMode = DisplayMode.View && Gallery_Expenses.Selected.Status.Value = "Draft" || "Declined by Accounting" || "Declined by Manager" || "Declined by CFO" && User().Email <> Gallery_Expenses.Selected.'Created By'.Email,
        true,
        If(
            'Form_View/Edit'.DisplayMode = DisplayMode.View && Gallery_Expenses.Selected.Status.Value <> "Draft" || "Declined by Accounting" || "Declined by Manager" || "Declined by CFO" && User().Email <> Gallery_Expenses.Selected.'Created By'.Email,
            true,
            If(
                'Form_View/Edit'.DisplayMode = DisplayMode.View && Gallery_Expenses.Selected.Status.Value <> "Draft" || "Declined by Accounting" || "Declined by Manager" || "Declined by CFO" && User().Email = Gallery_Expenses.Selected.'Created By'.Email,
                false,
                false
            )
        )
    )
)
Categories:
I have the same question (0)
  • Suggested answer
    KeithAtherton Profile Picture
    3,705 Most Valuable Professional on at
    Hey. What happens if you try this Power Fx?:
    'Form_View/Edit'.DisplayMode = DisplayMode.View
      && (Gallery_Expenses.Selected.Status.Value = "Draft"
      || "Declined by Accounting" || "Declined by Manager"
      || "Declined by CFO")
      && User().Email = Gallery_Expenses.Selected.'Created By'.Email
     
  • Eeyore2005 Profile Picture
    119 on at
     
    Thank you.
    When I entered your formula into Visible property of the pencil icon, no other user saw the pencil icon (regardless of the status) and Created by user saw it only in status "Draft".
     
    All other users except for Created by should be able to see the pencil icon in all the statuses.
    Only the Created by should be restricted to only see the pencil icon in the three statuses when his action is required: Draft" || "Declined by Accounting" || "Declined by Manager" || "Declined by CFO"
     
    Maybe this visualization of the desired effect helps:
     
  • Suggested answer
    KeithAtherton Profile Picture
    3,705 Most Valuable Professional on at
    Thank you, the visualization helps. I just realised an issue with my previous Power Fx code snippet - does this new Power Fx code snippet behave differently?:
    'Form_View/Edit'.DisplayMode = DisplayMode.View
      && (Gallery_Expenses.Selected.Status.Value = "Draft"
      || Gallery_Expenses.Selected.Status.Value = "Declined by Accounting"
      || Gallery_Expenses.Selected.Status.Value = "Declined by Manager"
      || Gallery_Expenses.Selected.Status.Value = "Declined by CFO")
      && User().Email = Gallery_Expenses.Selected.'Created By'.Email
     
  • Eeyore2005 Profile Picture
    119 on at
     
    Thank you, now it works perfectly for Created by person, but others do not see the pencil icon at all. And they should be able to see the icon in all the statuses in view mode. Could you please advise?
     
    Thank you again ;)
  • Suggested answer
    enriqueglopez Profile Picture
    503 Moderator on at
    Please, try this
     
    With(
        {
            currentStatus: Gallery_Expenses.Selected.Status.Value,
            createdBy: Gallery_Expenses.Selected.'Created By'.Email
        },
        If(
            'Form_View/Edit'.DisplayMode = DisplayMode.View And
            currentStatus in ["Draft", "Declined by Accounting", "Declined by Manager", "Declined by CFO"] And
            User().Email = createdBy,
            true,
            false
        )
    )
  • Eeyore2005 Profile Picture
    119 on at
     
    Thank you for your advice, it again works only for created by, but not for other users.
    I achieved what I need with the formula below. I know it is too long and untidy, but at least it works :)
     
    If(
        'Form_View/Edit'.DisplayMode = DisplayMode.View && (Gallery_Expenses.Selected.Status.Value = "Draft" || Gallery_Expenses.Selected.Status.Value = "Declined by  Accounting" || Gallery_Expenses.Selected.Status.Value = "Declined by Manager" || Gallery_Expenses.Selected.Status.Value = "Declined by CFO" )&& User().Email = Gallery_Expenses.Selected.'Created By'.Email,
        true,
        If(
            'Form_View/Edit'.DisplayMode = DisplayMode.View &&( Gallery_Expenses.Selected.Status.Value = "Draft" || Gallery_Expenses.Selected.Status.Value = "Declined by  Accounting" || Gallery_Expenses.Selected.Status.Value = "Declined by Manager" || Gallery_Expenses.Selected.Status.Value = "Declined by CFO" )&& User().Email <> Gallery_Expenses.Selected.'Created By'.Email,
            true,
            If(
                'Form_View/Edit'.DisplayMode = DisplayMode.View && (Gallery_Expenses.Selected.Status.Value = "Awaiting 1st Approval (Accounting)" || Gallery_Expenses.Selected.Status.Value = "Awaiting 2nd Approval (Manager)" || Gallery_Expenses.Selected.Status.Value = "Awaiting 3rd Approval (CFO)" || Gallery_Expenses.Selected.Status.Value = "Fully approved" || Gallery_Expenses.Selected.Status.Value = "Booked" )&& User().Email = Gallery_Expenses.Selected.'Created By'.Email,
                false,
                If(
                    'Form_View/Edit'.DisplayMode = DisplayMode.View && (Gallery_Expenses.Selected.Status.Value = "Awaiting 1st Approval (Accounting)" || Gallery_Expenses.Selected.Status.Value = "Awaiting 2nd Approval (Manager)" || Gallery_Expenses.Selected.Status.Value = "Awaiting 3rd Approval (CFO)" || Gallery_Expenses.Selected.Status.Value = "Fully approved" || Gallery_Expenses.Selected.Status.Value = "Booked" )&& User().Email <> Gallery_Expenses.Selected.'Created By'.Email,
                    true,
                    If(
                        'Form_View/Edit'.DisplayMode = DisplayMode.View && (Gallery_Expenses.Selected.Status.Value <> "Draft" || Gallery_Expenses.Selected.Status.Value <> "Declined by  Accounting" || Gallery_Expenses.Selected.Status.Value <> "Declined by Manager" || Gallery_Expenses.Selected.Status.Value <> "Declined by CFO" )&& User().Email = Gallery_Expenses.Selected.'Created By'.Email,
                        false,
                        If(
                            'Form_View/Edit'.DisplayMode = DisplayMode.View && (Gallery_Expenses.Selected.Status.Value <> "Draft" || Gallery_Expenses.Selected.Status.Value <> "Declined by  Accounting" || Gallery_Expenses.Selected.Status.Value <> "Declined by Manager" || Gallery_Expenses.Selected.Status.Value <> "Declined by CFO" )&& User().Email <> Gallery_Expenses.Selected.'Created By'.Email,
                            true,
                            false
                        )
                    )
                )
            )
        )
    )
  • enriqueglopez Profile Picture
    503 Moderator on at
    Eeyore2005 Try this to optimize the formula :)
     
    If(
        'Form_View/Edit'.DisplayMode = DisplayMode.View,
        If(
            User().Email = Gallery_Expenses.Selected.'Created By'.Email,
            If(
                Gallery_Expenses.Selected.Status.Value in ["Draft", "Declined by Accounting", "Declined by Manager", "Declined by CFO"],
                true,
                false
            ),
            If(
                Gallery_Expenses.Selected.Status.Value in ["Awaiting 1st Approval (Accounting)", "Awaiting 2nd Approval (Manager)", "Awaiting 3rd Approval (CFO)", "Fully approved", "Booked"],
                true,
                false
            )
        ),
        false
    )
     
  • Eeyore2005 Profile Picture
    119 on at
     
    Now it works perfectly for Created by and only partially for other users.
    Other users should see the pencil icon in all the statuses in view mode, but currently they only see it in these statuses: "Awaiting 1st Approval (Accounting)", "Awaiting 2nd Approval (Manager)", "Awaiting 3rd Approval (CFO)", "Fully approved", "Booked".

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard