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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Check condition and pa...
Power Apps
Unanswered

Check condition and patch based on Values on SharePoint lists

(0) ShareShare
ReportReport
Posted on by 997 Super User 2024 Season 1

Hi, I have 3 Sharepoint lists that are related to each other; 'Leave Request', 'Employee' and 'Approvers'. The employees apply for leaves in the 'Leave Request' list, and their names are added before that in the 'Employee' list. The employees' approvers, approval type and level are determined in the 'Approvers' list. The lists are related by from the 'Leave Request' list contains the Requester name, and it matches the name in the 'Employee' list where it has a column, Approval Type that will match in the 'Approvers' list to determine who is/are the approver(s) for that employee. All the employees and approvers columns are people columns.

anonymous21_1-1660807183365.png      

anonymous21_2-1660807287514.pnganonymous21_3-1660807500103.png

 

I've set the item level permission in the 'Leave Request' list so that only the requester and his approvers can view the item. The approval for the leave request is approved or rejected on the item in the 'Leave Request' list.

anonymous21_4-1660808027237.png

 

My problem is how to check which level the current user logged in is and how to make the approval multi-level. The approval is multiple and hierarchical. If the Level 1 Approver hasn't approved the leave request then it won't go through the Level 2 Approver or Level 3 Approver and so on. When an item is created in the 'Leave Request' list, the Status will be pending and the Level1 Approver will need to click Approve button and then it will patch the Approval Status to indicate that Level 1 Approver has approved, pending Level 2 Approver and so on. Then Level 2 approver approves the leave request, then it will patch the Approval Status as Level 1 has approved, Level 2 has approved, if there is another level then it will pending the level.

 

 

//App.OnStart
Set(IsApprover, LookUp(Approvers, Approver.Email = CurrentUser).Approver.Email);
Set(ApproverByType,LookUp(Approvers,CurrentUser=IsApprover).Title);
Set(ApproverLevel, LookUp(Approvers, ApproverByType = CurrentUser).Level);
Set(checkApprovers,Filter(Approvers, Approver.Email = CurrentUser));

 

 I set the variables and use them on Button Approver visible property -> If(CurrentUser=IsApprover) to check the approver. But it doesn't really work out the way I want and I'm not sure how to achieve this. Can someone please help me?

 

Thank you.

Categories:
I have the same question (0)
  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    Hi,

     

    I think you may find this one useful: PowerApps Approvals without using Flow - YouTube

     

    Also, you may consider extending the status options, lets say Pending Level 1, Pending Level 2,... this may help you sort which items to show to the logged in approver.

     

    Regards.

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    Hi @jcfDaniel, thank you for that recommendation. The video only shows single-level approval whereas I need multi-level approval. Do you have any other way or recommendation?

     

    Thank you.

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    My idea for that is the Status of the request, expanding it so it can support the request's cycle from pending to fully approved. For instance, you can have your Level 2 approvers seeing only requests that are the Level 1 Approved Status.

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @jcfDaniel Do you mean create columns for each approvers' status?

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    No. The Status column is a choice, right? Add choices to it.

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @jcfDaniel Oh, I get it now. How to check the current user logged in is which level and approval type? I tried using my formula but it doesn't really work.

     

    Thank you.

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    Hi,

     

    You can maybe leverage User().Email. If the approvers table has the email of the approver it should be simple.

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    Hi @jcfDaniel,

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

    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"}})
    ));

     

    Thank you.

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    Hi,

     

    I was going in a different direction, filtering records according to the level of the approver. Let's say you have 3 requests, 2 in Level1 and 1 in Level and that I am a Level1 approver, in a let's say a gallery, the records could be filtered. something like Filter(RequestsDataSource, Status = varApprover.Level) //this is somewhat simplified

     

    Wuth the filtered records, an approve button would do for patching. Do you think this would work?

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    Hi @jcfDaniel, I think it would work but I don't use a gallery. It's just the list items on the Sharepoint list for all the requests. If you are the approver level 1, then you can approve the request then it will patch the pending approval for approver level 2 and so on.

     

    I create a collection with this formula to filter the current user.  But I'm not sure how to enable the approval multi-level checking.

     

    Clearcollect(approverlist,Filter( ShowColumns(Approver,s 'Title',"Approver","Level"),Approver = User().Full Name));
    ClearCollect(checkApprovers,Filter(Approvers, Approver.Email = CurrentUser));

     

     

    "I was going in a different direction, filtering records according to the level of the approver. "

    This is what I want as well but I'm not really sure how to do that. So my formula won't work that way?

     

    Thank you.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 379 Most Valuable Professional

#2
11manish Profile Picture

11manish 203 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard