cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
syhrh
Dual Super User
Dual Super User

Current user's level for multi-level approval

Hi, I have a Leave Request list that requires approvals on the clicked item on that list.

 

anonymous21_2-1660878979688.png      

anonymous21_3-1660879309041.png

I want to check the level of the approver(s), if the current user is the last approver there is to approve the request. If yes, then patch "Approved" in the Status column. If not, then patch Pending for Approver Level 2 or 3 and so on. The checking is based on Approvers List where the Approver column is a people column. It is based on the Level column. I've set the item level permission so that only the requester and their approver(s) can view the item but I don't know how to do the multi-level approval in Power Apps.

 

         anonymous21_1-1660878945309.png

This formula filtered all the current user data from the Approver's list. How to check/set the current user's level from the collection and then use it to patch for other approvers if applicable? Can anyone please help me?

ClearCollect(checkApprovers,Filter(Approvers, Approver.Email = CurrentUser));

 

Thank you.

 

 

8 REPLIES 8
AJ_vizMan
Helper V
Helper V

@syhrh  - One way of solution is below
1. Create a collection using 'On Start' of app as below 
Set(Myprofile, User().Full Name);

Clearcollect(approverlist,Filter( ShowColumns(Approver, 'Title',"Approver","Level"),Approver = User().Full Name))

// If you are using email id under Approver column than use User().Email

2. Now, use 'Display' Property on submit button (from where you want to achieve the functionality)
if(Myprofile in approverlist, patch( yourlistName, Thisitem.id,  Status = "Approved"), patch( yourlistName, Thisitem.id, Status = "Pending"))

// Here i am assuming that you need to have status value for each item. And 'Status' column is there in yourlistName

Hi @AJ_vizMan 

I tried your formula but I got 1 error. This is OnSelect.Button

anonymous21_0-1660892579009.png

 

AJ_vizMan
Helper V
Helper V

@syhrh  - oh, my bad.

use approverlist.Approver

phipps0218
Super User
Super User

If you are wanting multi-level approvals I would suggest using Teams Approval and you can configure that to be the case. On receiving all approvals you can then update the item status. 

@AJ_vizMan 

I got this error

anonymous21_0-1660894118935.png

 

@phipps0218 I couldn't use Teams as I'm required to create the approvals on the SharePoint site. Thanks for the suggestion.

It would be a much neater solution and this is what I tend to do 🙂

@AJ_vizMan 

 

If(
    LookUp(checkApprovers,CurrentUser=Approver.Email) in approverlist , 
    Patch('Leave Request',LookUp('Leave Request',ID=SharePointIntegration.SelectedListItemID), 
    {Status:{Value:"Approved"}}), 
    Patch( 'Leave Request',LookUp('Leave Request',ID=SharePointIntegration.SelectedListItemID,  
    {Status:{Value:"Pending"}})
));

 

ClearCollect(checkApprovers,Filter(Approvers, Approver.Email = CurrentUser));

I do this formula but how to check which level is the current user? And how to patch it?

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,060)