I need to make a filter so that only the current user can see their approval requests
Solved! Go to Solution.
Hi @octaking ,
Where do you put your formula? Within Gallery Items property?
If you put your formula within the Gallery Items property, please modify your formla as below (set the Items property of the Gallery to following formula😞
Filter(
AddColumns(Approvals; "OwnerName", AsType(Owner, Users).'Full Name'); /* <-- Modify formula here. Type Owner rather than ThisItem.Owner */
Status = 'Status (Approvals)'.Inactive; /* <-- If you want to list Active Approval requests, please type 'Status (Approvals)'.Active */
Result <> "Approve" && Result <> "Reject";
OwnerName = User().FullName
)
Please take a try with above solution, check if the issue is solved.
Best regards,
You'll need another field inside your collection or data source that stores the user's info and then add an additional filter on top of your current filter. For example,
Filter(Approvals, Status = 'Status (Approvals)'.'0', Result <> "Approve" && Result <> "Reject" && UserField.Email = User().Email)
Hi @hnguy71
I understand, but in this case UserField is the owner and I can't get it
Do you have an idea of this?
Oh you're trying to filter by who created the record? Honestly, you shouldn't rely on the default fields that CDS has. It's better that you create your own new field and call it something generic like RecOwner and as you create a new entry, drop the current user's name into the field. The field you're trying to pull is a lookup field and is out of scope. If you don't want to create a custom field then this formula might work for you:
Filter(Approvals, Status = 'Status (Approvals)'.'0', Result <> "Approve" && Result <> "Reject" && User().FullName in 'Created By'.'Full Name')
Hi @octaking ,
Do you want to filter your approval requests based on current login user?
I have made a test on my side, please take a try with the following workaround:
Firstly, you need to add Users Entity as data source within your app.
Then please modify your formula as below:
Filter(
AddColumns(Approvals; "OwnerName", AsType(ThisItem.Owner, Users).'Full Name');
Status = 'Status (Approvals)'.Inactive; /* <-- If you want to list Active Approval requests, please type 'Status (Approvals)'.Active */
Result <> "Approve" && Result <> "Reject";
OwnerName = User().FullName
)
Note: The Users represents the Users Entity in your CDS. Currently, there is no way to compare AsType(Owner, Users).'Full Name' formula and User().FullName formula directly within Filter function.
Please take a try with above solution, then check if the issue is solved.
More details about the polymorphic lookups in CDS, please check the following blog:
https://powerapps.microsoft.com/en-us/blog/owner-customer-and-regarding-for-canvas-apps/
Best regards,
Hi @octaking ,
Where do you put your formula? Within Gallery Items property?
If you put your formula within the Gallery Items property, please modify your formla as below (set the Items property of the Gallery to following formula😞
Filter(
AddColumns(Approvals; "OwnerName", AsType(Owner, Users).'Full Name'); /* <-- Modify formula here. Type Owner rather than ThisItem.Owner */
Status = 'Status (Approvals)'.Inactive; /* <-- If you want to list Active Approval requests, please type 'Status (Approvals)'.Active */
Result <> "Approve" && Result <> "Reject";
OwnerName = User().FullName
)
Please take a try with above solution, check if the issue is solved.
Best regards,
User | Count |
---|---|
165 | |
90 | |
72 | |
64 | |
62 |
User | Count |
---|---|
211 | |
152 | |
96 | |
86 | |
66 |