cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
octaking
Helper V
Helper V

Filter formula

I need to make a filter so that only the current user can see their approval requests

 

Captura de Pantalla 2019-08-18 a la(s) 12.31.05.png

1 ACCEPTED SOLUTION

Accepted Solutions

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
hnguy71
Helper V
Helper V

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?

Captura de Pantalla 2019-08-18 a la(s) 14.15.01.png

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')
v-xida-msft
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xida-msft 

It doesn't work for me

69059534_2391815307734163_8702630522347585536_n.jpg

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @v-xida-msft 

Thank you very much for your help it worked

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,018)