Skip to main content

Notifications

Announcements

No record found.

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

  • Community Member Profile Picture
    Community Member Microsoft Employee 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
    joenewstrom 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
    Royal King 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
    Ferdy Griffioen 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
    CU20091903-0 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
    Linn Zaw Win 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
    BiR 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
    BiR 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
    Ferdy Griffioen 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
    Community Member Microsoft Employee 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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,820 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans