Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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
            )
        )
    )
)
  • Eeyore2005 Profile Picture
    119 on at
    If condition in the visible property
     
    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".
  • enriqueglopez Profile Picture
    475 Super User 2025 Season 1 on at
    If condition in the visible property
    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
    If condition in the visible property
     
    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
                        )
                    )
                )
            )
        )
    )
  • Suggested answer
    enriqueglopez Profile Picture
    475 Super User 2025 Season 1 on at
    If condition in the visible property
    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
    If condition in the visible property
     
    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
    KeithAtherton Profile Picture
    3,646 Most Valuable Professional on at
    If condition in the visible property
    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
    If condition in the visible property
     
    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,646 Most Valuable Professional on at
    If condition in the visible property
    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
     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard