Hi, I have a Leave Request list that requires approvals on the clicked item on that list.
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.
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.
@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
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.
@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 🙂
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?
User | Count |
---|---|
261 | |
130 | |
99 | |
48 | |
45 |