Comment unsuccessful. Please correct the errors below.

Displaying inactive records in associated view

Associated views have always been a sore subject in CRM. When CRM 3 was released, they did not include inactive records and, despite the ever present Activate menu item, there was no any way to actually show all associated records not just active ones. People complained. Then rollup 2 changed the behaviour. People complained. Then there was a hotfix for custom entities. People complained that it should be available for system entities as well. CRM 4 is released and hotfix no longer works. People complain.

Plug-ins to the rescue

The good news is that CRM 4 plug-in model is flexible enough to solve this problem once and for all. The idea is to intercept RetrieveMultiple message and modify its query so that all associated records are returned. And the code is surprisingly simple:


  

using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Query;

namespace Acme.Plugins
{
    public class AssociatedViewPlugin : IPlugin
    {
        public void Execute(IPluginExecutionContext context)
        {
            if (context.InputParameters.Contains(ParameterName.Query))
            {
                QueryExpression qe = context.InputParameters[ParameterName.Query] as QueryExpression;
                // If it's RetrieveMultiple multiple with two conditions
                if (qe.EntityName == context.PrimaryEntityName
                      && qe.Criteria != null
                      && qe.Criteria.Conditions != null
                      && qe.Criteria.Conditions.Count == 2)
                {
                    // If first condition is a statecode filter for inactive entities
                    ConditionExpression ce = qe.Criteria.Conditions[0] as ConditionExpression;
                    if (ce != null
                        && ce.AttributeName == "statecode"
                        && ce.Operator == ConditionOperator.Equal
                        && ((int)ce.Values[0]) == 0)
                    {
                        // Remove statecode filter
                        qe.Criteria.Conditions.Remove(ce);
                    }
                }
            }
        }
    }
}

Installation

  1. Compile the code and sign the assembly.
  2. Using Plug-in Registration Tool register the plug-in.
  3. Register execution step for the entity that you'd like to show all records in associated views. Note that we use PreStage (a.k.a. BeforeMainOperationOutsideTransaction) and Synchronous execution mode. For example, to always show inactive contacts in associated view:
    image
  4. Optionally add Status column to the associated view for the entity not to confuse users.
  5. Rinse and repeat 3-4 for other entities.

The result for the Contacts associated view inside account entity:

image

At long last Activate menu command makes sense.

Note: this code is a sample only and is included "AS IS" without any warranties whatsoever. In Real Life™ more stringent tests would have to be performed to ensure that RetrieveMultiple message indeed originated from the associated view and was not sent by your poor fellow co-worker complaining (or, worse still, raising support request with Microsoft) about filtering state code not working.

Posted by: George Doubinski
Last revised: 05 Dec, 2012 05:25 PM

Comments

10 Mar, 2008 11:25 AM

Just implemented this plugin and it works perfectly!

Thanks George!

June Brehm
June Brehm
09 Jun, 2014 05:18 AM

This information is very useful. Especially for us students. buy twitter followers

19 Sep, 2014 08:40 AM

Thanks for discussing your ideas with this blog. In addition, a Fantasy Regarding the banks Intentions while Talking About Foreclosure is that the Financial Institution will not Take My payments. situs sbobet There is a Certain Amount of time that the Bank will require payments from time to time . If you are far TOO deep Inside hole, they'll commonly demand that you Pay that Payment in full. However, I AM not saying that they will not Take any Sort of repayments at all. In the event you and the lender can manage to work some thing out, a Foreclosure Process May end. However, should you Continue to Miss payments in the new Strategy, the Home Foreclosure Process can pick up WHERE it was left off.

24 Dec, 2014 07:07 AM

Hi pal, that was a good post.

Humberto B. Peterman
Humberto B. Peterman
10 Mar, 2015 09:15 PM

Do you know what is the reason behind your low grades in essay assignments? If no then you should stay aware of what your class mates are doing. They are buying services from professionals and you also need to get custom essay if you wanted to get better grades in the class.

ram15
ram15
22 Apr, 2015 07:10 AM

The idea is to focus on facts and try and define a baseline problem to share. Best school in rewari

James Jane
James Jane
29 Dec, 2015 11:16 AM

You have shared great points to install this plugins registration and activation information. Its very useful plugin for checking records of students. UK interlocking horse mats

mike
mike
30 Dec, 2015 11:56 AM

You have posted very nice tutorial,i like reading it.Such tutorials are very helpful for students. grass mats

09 Feb, 2016 03:31 PM

This article is very good and useful for readers. thank you for sharing knowledge cara menggugurkan kandungan

12 Feb, 2016 12:26 PM

thanks for posting and sharing information through this very useful

Isabella
Isabella
01 Apr, 2016 09:22 AM

The number of institutes are doing the great work by engage the adults and the youth in studies and providing the positive parenting classes assignment help which is good for their mind growth and development of capabilities.

Jack Ryan
Jack Ryan
13 Apr, 2016 04:27 PM

Assembly language is low level language and that is close to the computer languages. That source code is quite helpful and the programmer can easily understand that bestessays piece of code and its functionality.

coper
coper
14 Apr, 2016 07:10 AM

Ray Ban sun shades action different Cheap Ray Ban administration and aswell effortless cool. Giving you the befalling to abrasion a cast in which looks air-conditioned contemporary and aswell appropriately elegant, Ray Ban eyewear is a accept to if you are austere about getting elegant. Whether you're analytic apropos simple and beautiful or conceivably ultra glamorous, Ray Ban can address to all tastes. As just about the a lot of accepted cast extensions apropos Ray Ban, the sunglasses ambit is accepted and in Oakley sunglasses outlet demand. If you're aggravating to acquisition affluence artisan sunglasses again Ray Ban could be the cast to buy.Another acumen to abrasion superior sunglasses would be to accord a adolescent analytic appearance. Keeping your appointment analytic younger, by the abridgement of furnishings from the sun can Cheap Ray Ban outlet accomplish you attending adolescent total.

24 Dec, 2016 09:10 AM

192.168.1.1 is the IP address that is commonly used by ADSL modems to configure and access to the router configuration panel.

20 Jan, 2017 10:10 AM

Be a Part of the No.1 Video Sharing Community. With VivaVideo, you can easily create professional-looking video stories within a few taps.

20 Jan, 2017 10:11 AM

Be a Part of the No.1 Video Sharing Community. With VivaVideo, you can easily create professional-looking video stories within a few taps.vivavideo 

henry
henry
22 Feb, 2017 04:47 PM

Great post you have shared with everyone, with great posting style. I am very happy to read your post, and must want to say bookmark this stuff for future updates. pay per call marketing

01 Mar, 2017 10:54 AM

What a great post is it. I really impressed to read the great information that you have posted. I appreciate your efforts that you have made to create this great post. Keep this great work up.

31 Mar, 2017 05:37 AM

Download the latest version of pokemesh android download file easy and fast.

alex
alex
06 Apr, 2017 11:50 AM

Very informative article about associative views in CRM,you have written about it in detail which makes it easy to understand. purchase switch board matting online

MerlinTip
MerlinTip
08 Apr, 2017 08:57 PM

[url=https://www.kristiinakoskentola.nl/images/kristiinakoskentola/856-nike-air-force-1-high-id.jpg]Nike Air Force 1 High Id[/url] Fear can be a protection process, so we should not only accept that it's good to obtain anxiety, but recognize that we're satisfied our mental abilities are seeking to safeguard us when there exists a panic attack. The secret is to let our minds understand that what it fears isn't actually over to injured us, but many thanks for seeking.

þÿ

Should you be selling your property, it is very important keep an eye on any foreclosures in the community. Do not collection your house if you can find any one of these components currently out there. Wait until they sell, or you might be made to decrease the cost of your own house to stay competing. [url=https://www.sanysad.es/images/sanysad/2436-nike-zapatos-mujer-botines.jpg]Nike Zapatos Mujer Botines[/url]

þÿ

04 May, 2017 08:54 AM

I just wish WhatsApp had moved a while more associated an individual approach

15 May, 2017 11:35 AM

Aptoide download for Android, Tablet, iPhone, iPad, PC and Smartphones

17 May, 2017 06:33 AM

As per some sources, it is expected that the new iPhone 8 will be costlier but provide you whole features which you imagine to own on your mobile device

Thomascok
Thomascok
25 Sep, 2017 12:54 PM

[url=http://www.fenger.nu/tommy-hilfiger-jeans-dame-497.html]Tommy Hilfiger Jeans Dame[/url] Whenever you can function as the initial man or woman to discuss a subject, that's your best option for information. Speak about stuff you really are an expert in and provide tips which can't be seen in other places. Whenever people see that what you're giving isn't located on other internet sites, they'll look at your blog being the specialist inside the discipline.

[img]https://www.saturate.nu/imagess/sat2/4024-carrera-aurinkolasit-suomi.jpg[/img]

Ensure the fastens with a home that you would like to acquire are changeable. It is because you should change your hair once the property is yours. One never knows when the previous created duplicates from the tips and therefore has access to your home. In the event the residence has a alert system, be sure to change the program code.

[img]https://www.karateklubben.nu/imagess/kar2/1782-adidas-neo-erkek-spor-ayakkabı.jpg[/img]

11 Oct, 2017 09:43 AM

diwali images and wallpapers download it.

happy diwali happy diwali 2017

agsdfasf
agsdfasf
19 Oct, 2017 02:54 AM

Smooth bangs modified head type is more small face, buckle tail tail to hair extensions increase fashion sense, brown wear does not pick people, worn on human hair extensions the head more fashionable. Amber gray wig is very skinny, it is suitable for dark skin girls. And the design of clip in hair extensions the buckle can also modify the perfect face, become hair extensions online very fashionable and fashionable

07 Nov, 2017 07:54 AM

luckypatcherr.net Lucky Patcher net: People cannot work out with the same device all the time if there were no changes in it.

Bryceber
Bryceber
07 Nov, 2017 09:24 AM

[url=http://www.tverstedliv.dk/adidas-yeezy-boost-350-turtle-dove-385.php]Adidas Yeezy Boost 350 Turtle Dove[/url] To actually fix your credit history, you have to make positive changes to psychological state, also. This means building a specific plan, including a finances, and adhering to it. If you're accustomed to getting almost everything on credit, change to money. The psychological affect of parting with actual money cash is much in excess of the abstract future effect of purchasing on credit history.

[img]https://www.kagetora.nl/images/kag2/339-nike-blazer-dames-bloemen.jpg[/img]

In case you are eliminating a well used charge card, cut up the charge card throughout the profile amount. This is particularly essential, should you be reducing up an expired card and your alternative greeting card offers the identical account number. As being an additional protection phase, think about putting together away the pieces in different rubbish totes, to ensure burglars can't item the card together again as quickly.

[img]https://www.cafe-manhattan.dk/images/caf2/1546-abercrombie-børn.jpg[/img]

12 Nov, 2017 07:04 AM

Nice bag you can earn money from that Thanks for your posting Visit me @,

Your Comments

Comment unsuccessful. Please correct the errors below.
Used for your gravatar. Not required. Will not be public.
Posting code? Indent it by four spaces to make it look nice. Learn more about Markdown.

Preview