cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

CDS Contacts search with Lookup : Delegation issue

Hi Community,

 

I'm trying to implement a CDS Contacts search feature and I'm fighting with delegation issue. The app should be able to search for contacts (easy), accounts (easy) AND contacts related to found accounts (this is where the issue stands).

 

Here is the formula I have so far:

If(!IsBlank(Trim(TextSearchBox1.Text)); 
Concurrent(
ClearCollect(ContactsFound;Filter(Contacts; Trim(TextSearchBox1.Text) in 'Full Name' ));
ClearCollect(AccountsFound;Filter(Accounts; Trim(TextSearchBox1.Text) in 'Account Name').Account)
);;
Collect(ContactsFound;Filter(Contacts; AsType('Company Name';[@Accounts]).Account in AccountsFound))
;Blank())

 

The last Collect is where delegation warning is reported.

 

I cannot find a way to avoid PowerApps to download all contacts to evaluate the Filter. Is there a way to do this? It seems there is no way to delegate a search against CDS Lookup field type...

 

Anyone would have a magical trick for me?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @TanguyT ,

 

'Company Name' is polymorphic lookups  field, and the AsType() function is not delegable in Filter formula.

If you change to use a common LookUp field, then the ForAll() formula will work properly without any delegation warnning.

Snipaste_2020-07-08_14-46-07.png

Hope this helps.

Sik

 

View solution in original post

8 REPLIES 8
Super User
Super User

See this post from @PowerAddict  https://powerusers.microsoft.com/t5/Building-Power-Apps/CDS-Contacts-search-with-Lookup-Delegation-i...

 

One thing that can make delegatable functions non delegatable is if. 

 

@jlindstrom the link your gave is the link of this current thread. Can you give the appropriate link?

 

Thanks

Thank you @jlindstrom  but I don't think it fits my problem.

 

What I'm after is to understand how to filter contacts based on parentcustomerid with multiple accounts unique identifier in a delegated way.

 

In the end, I would like the query performed to be something like the following if I retrieved 3 accounts $filter=_parentcustomerid_value eq xxxx or _parentcustomerid_value eq yyyy or _parentcustomerid_value eq zzz

Ok, i misread your original query.  I think the delegation issue is with in. I've had to do this one time before and I can't find the example, but I think it was something like what is in this post: https://powerusers.microsoft.com/t5/Building-Power-Apps/How-to-filter-data-based-on-a-collection-in-...

 

 

Collect(anotherCollection, Lookup(CustomerList, Customer_ID = Result))

I tried the ForAll approach but the delegation warning is just moved from "=" to "AsType" code

 

If(!IsBlank(Trim(TextSearchBox1.Text)); 
Concurrent(
ClearCollect(ContactsFound;Filter(Contacts; Trim(TextSearchBox1.Text) in 'Full Name' ));
ClearCollect(AccountsFound;Filter(Accounts; Trim(TextSearchBox1.Text) in 'Account Name').Account)
);;
ForAll(AccountsFound;
Collect(ContactsFound;Filter(Contacts; AsType('Company Name';[@Accounts]).Account = Account))
)
;Blank())

Hi @TanguyT ,

 

'Company Name' is polymorphic lookups  field, and the AsType() function is not delegable in Filter formula.

If you change to use a common LookUp field, then the ForAll() formula will work properly without any delegation warnning.

Snipaste_2020-07-08_14-46-07.png

Hope this helps.

Sik

 

View solution in original post

Thank you that helps to understand but not to resolve the issue. I have to use parentcustomerid customer field. 

 

But I got the point and will see if I can duplicate the info in a dedicated lookup field

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Check out the Power Apps Community Call for January 2021

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (4,174)