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 / Show/hide approval but...
Power Apps
Unanswered

Show/hide approval buttons if user is listed as an approver in form feeding SharePoint and if the prior approval level is complete

(0) ShareShare
ReportReport
Posted on by 82

I have a formula that shows approval buttons for a request if the current user() is listed as an approver. How do I add a statement to my current formula that shows the approval buttons if the current user is listed as an approver and the prior level is complete, otherwise hide buttons? Please note there can be multiple approvers at each level.

Aliyah1_2-1688075222398.png

 

 

Categories:
I have the same question (0)
  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    Hi @Aliyah1 ,

     

    What does "prior level is complete" mean?

  • Aliyah1 Profile Picture
    82 on at

    Hi @Amik

     

    In this case, if all of the 'Dept HR Liaisons' approve the request, then that level of approval is complete and now the 'Dept Head' must approve.

  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    Hi @Aliyah1 ,

     

    What does that mean in terms of logic. Is "Dept HR Liaisons" a field for example?

     

    I notice in your patch you have a field called "Dept HR Liaisons Approve" - should the button be visible if that field equals "Approved" ?

     

    You have provided very limited detail.

     

  • Aliyah1 Profile Picture
    82 on at

    Hi @Amik,


    It is a multi-level sequential approval.
    When the request is initially submitted, the requestor is required to select the Dept HR Liaisons. ‘Dept HR liaisons’ is a Person(s) field in the SharePoint list. If the program user() is listed in that person(s) field, the approve, decline and need more information buttons become visible. If they are not listed, then the buttons are hidden. 

     

    Once the HR Liaison approves the request, “approve” is populated into a multi-text column in Sharepoint titled ‘HR Liaisons Response.’


    After they all respond, the last approver should be prompted to select the ‘Dept Head’ approver, which feeds to another Person(s) column in the Sharepoint list.

     

    Once the ‘Dept Head’ person(s) column is populated, the HR liaisons should no longer be able to see the approval buttons because their part of the process is complete. This is the part I’m trying to add to the formula…

     

    the approval buttons should only be visible to the users listed in ‘dept head’ person(s) column, at this point in the process.

  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @Aliyah1 ,

     

    I assume you're using an expression/some logic to identify when the last approver has responded in order to prompt them to select a department head.

     

    How does that expression work? Because we can re-use that expression as one of the conditions to hide the button.


    E.g. If all Dept HR Liaisons have approved AND the current user = the department head, then display the buttons, otherwise hide them

  • Aliyah1 Profile Picture
    82 on at

    Hi @Amik , 

     

    That’s the expression I need help with. My current expression just says if the word approved, in the multiline text box, is equal to the number of people selected from the persons column then show pop up box.
    (I.e. if there are two approvers selected, then there must be two “approves” before the box displays itself)

    I’ll rather set it up the way you described it in your example though.

  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @Aliyah1 ,

     

    As I understand it, a user submits an approval request. They enter the names of the approvers in a multi-choice person field (called Dept HR Liaisons).

     

    Each approver has to approve the request and the approval buttons should only become visible if the current app user exists in a multi-choice person field (which I now remember we already solved in a different post).

     

    When a approver has approved a request, a multi-line text field is updated with the word "Approved". When another approver approves a request, the same field is appended with "Approved"

     

    You then want to check if the number of people in the Dept HR Liaisons field is equal to the number of times "Approved" appears in the multi-line field. If the count of both are the same, then the single select Department Head People field should be visible.

     

    Amik_3-1688683068949.png

     

    Notice only items 2 and 3 have Department Heads, because the count of "Approved" is equal the number of approvers.

     

    This is possible. But I must caveat it would make more sense to track the approvals in a separate SharePoint list, with a new line per approver and response.

     

    Anyway, try the Solution below:

     

    Add a Label into your screen and in the Text property, enter:

     

    LookUp(
     'Your Data',
     ID = 'Your Unique ID',
     Concat(
     'Your People Column',
     ThisRecord.Email & ","
     )
    )

     

    Add another Label into your screen and in the Text property, enter:

     

    LookUp(
     'Your Data',
     ID = 'Your Unique ID',
     'Your Multi-line text column'
    )

     

    Add another Label and apply to the below to the Text property. You can of course use the same expression for anything else you need, such as whether the Buttons should be visible:

     

    Value(//Count people in HR Liaisons field
     CountRows(
     Filter(
     Split(
     'Your Approvers Label'.Text,
     ","
     ),
     Value <> ""
     )
     )
    ) = Value(//Count occurrences of the word "Approved"
     CountIf(
     Split(
     'Your Responses Label'.Text,
     ","
     ),
     "Approved" in Value
     )
    ) && LookUp(
     'Your Data',
     ID = 'Your Unique ID',
     'Department Head'.Email = User().Email
    )

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Imran-Ami Khan

  • Aliyah1 Profile Picture
    82 on at

    Hi @Amik ,

     

    Thank you for your response! If I took your advice and tracked the approvals in a separate SharePoint list, with a new line per approver and response, what functions would I use? Patch?

  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @Aliyah1 , yes you would almost certainly use a Patch. You want to end up with a Table like below (on the Left) which you can easily manipulate. See the example Table on the Right which counts the number of approvers vs the number who have approved.

     

    Amik_0-1688757901030.png

     

    However, I still think even this approach could be unnecessarily complicated as what you're trying to do is exactly the kind of scenario Power Automate is perfect for. I personally use because Power Automate for approvals in my Apps because it performs all of the difficult tasks for me out of the box. Additionally, when the customer inevitably asks for changes, it is easier to accommodate them using Power Automate, rather than writing/editing code.

     

    If you create a Start and wait for an approval action, you can set the Approval Type to “Custom Responses – Wait for all responses” – this action means the Flow will not proceed until all Approvers have responded. Alternatively you can create multi-level approvers, so that the Flow will not proceed until Person X or Person Y has approved.

     

    Amik_1-1688758339646.png

     

    Once you have all of the Approvals you need, you can get Power Automate simply update a SharePoint field (e.g. a Yes/No type field called "All Approved").

     

    You can then show/hide the buttons based on that field equalling true or "Yes".

     

    I would recommend doing more reading online in order to identify which approach best suits your App.

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Imran-Ami Khan

     

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