cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
octaking
Level: Powered On

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
Community Support Team
Community Support Team

Re: Filter formula

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.
8 REPLIES 8
hnguy71
Level 8

Re: Filter formula

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)

 

 

octaking
Level: Powered On

Re: Filter formula

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?

octaking
Level: Powered On

Re: Filter formula

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

hnguy71
Level 8

Re: Filter formula

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')
Community Support Team
Community Support Team

Re: Filter formula

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.
octaking
Level: Powered On

Re: Filter formula

Hi @v-xida-msft 

It doesn't work for me

69059534_2391815307734163_8702630522347585536_n.jpg

Community Support Team
Community Support Team

Re: Filter formula

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.
octaking
Level: Powered On

Re: Filter formula

Hi @v-xida-msft 

Thank you very much for your help it worked

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 130 members 4,284 guests
Please welcome our newest community members: