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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Using Linked-Entity in addCustomFilter

(0) ShareShare
ReportReport
Posted on by 25

At this moment I know how to use the addCustomFilter in combination with addPreSearch (and the remove variants). All this works perfectly when passing a filterXml like:

    <filter type="and">
      <condition attribute="name" operator="eq" value="test123" />
    </filter>

But I just can't figure out how to use linked-entities in the addCustomFilter and whether it is actually possible. I've tried the following:

    <link-entity name="account" from="accountid" to="parentaccountid">
      <filter type="and">
        <condition attribute="name" operator="eq" value="test123" />
      </filter>
    </link-entity>

It is still the same filter but it is now placed on the parent account of the account. With this filterXml I want to get all the accounts that have the account 'test123' as the parent account.

The problem is that the filter doesn't work in the addCustomFilter but it does return results in the AdvancedFind.

Is there a way to use linked-entities in the addCustomFilter method, if so what am I doing wrong?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Using Linked-Entity in addCustomFilter

    Joe Newstrom's answer is the correct one here, it worked for me perfectly.

  • Suggested answer
    joenewstrom Profile Picture
    6 on at
    RE: Using Linked-Entity in addCustomFilter

    You aren't going to be able to use addCustomFilter() but you will be able to use addCustomView.

    The cleanest, and most importantly, the *supported* way to handle your requirement is as follows:
    1. Download the FetchXML for the default query for the lookup (use advanced find).

    2. Download the FetchXML for the query that includes your custom filter (i.e. add the link-entity filter in advanced find).

    3. Create a javascript function that takes the two FetchXML queries as strings and conditionally replaces the default view using Xrm.Page.getControl().addCustomView()

    Using this method you can go multiple layers deep, conditionally cross filter among related lookups, etc. Pretty powerful stuff. addCustomFilter() is pretty compact but also very limited. addCustomView() removes the restrictor plate.

    HTH

    Joe

  • Royal King Profile Picture
    27,686 on at
    RE: Using Linked-Entity in addCustomFilter

    Take a look at this thread it has workaround. You can't add Linked entity filter in the AddcustomFilter method. You can filter only based on current record field values. In order to filter based on the linked entity either you need to get id's parent record based on condition then provide that id's in the filter criteria or you can use the work around provided int eh below thread..

    community.dynamics.com/.../137618.aspx

  • Ferdy Griffioen Profile Picture
    25 on at
    RE: Using Linked-Entity in addCustomFilter

    At this moment I haven't found a solution for the problem. (well our solution was to not support it to our users etc).

  • CU20091903-0 Profile Picture
    55 on at
    RE: Using Linked-Entity in addCustomFilter

    Hi Ferdy

    I am also faced with the exact same issue and I can't seem to crack it.

    Have you managed to find a solution for this yet?

    Kind Regards

  • Suggested answer
    Linn Zaw Win Profile Picture
    3,407 on at
    RE: Using Linked-Entity in addCustomFilter

    If the out of the box addCustomFilter method doesn't work for link entity conditions, try this custom addCustomFilter method

    madcomputerist.blogspot.com/.../adding-additional-condition-to-lookup.html

  • BiR Profile Picture
    180 on at
    RE: Using Linked-Entity in addCustomFilter

    I have also created a stackoverflow for your question:

    stackoverflow.com/.../using-linked-entity-in-addcustomfilter

  • BiR Profile Picture
    180 on at
    RE: Using Linked-Entity in addCustomFilter

    Have you found a solution?

    I am trying to do exactly the same.

  • Ferdy Griffioen Profile Picture
    25 on at
    RE: Using Linked-Entity in addCustomFilter

    @ Adam Vero,

    As I've state before, the XML you pass must start with 'filter'. Therefor I can't try your idea as it starts with 'link-entity'.

  • Community Member Profile Picture
    on at
    RE: Using Linked-Entity in addCustomFilter

    Have you tried this:

    <link-entity name="account" from="accountid" to="parentaccountid" link-type="outer">

    <filter... etc

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#3
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans