Friday, April 6, 2012

Showing the from, to, cc in Email Associated View

My previous post walked through the process of "IFraming" in an Advanced Find view into a CRM 2011 form (4.0-esque) when the occassion calls for it. In an earlier post, I also reviewed the challenges with trying to embed the actual CRM activities (email, phonecall, appointment, task, fax, etc.) into a parent form. This post will combine the two to show how we can use the embedded Advanced Find approach to work around the shortcomings of the entity-activities relationship.

By way of introduction - one of the issues with the standard "Closed Activities" view is that you are unable to view all the details of the activity in the grid display. The best example are emails which will appear under this view - you are unable to show the "from", "to", "cc" etc. in the Closed Activities view. The reason is quite simple - it is because the "activities" view is a super view that incorporates all the different types of sub-activities beneath it. It is in fact just a pointer to the actual activities (noteworthy: the actual underlying the database view is called activitypointer) and therefore it only includes the columns that are common to all activities.

That explains why it works like this but it doesn't really help us if in fact we wish to display these columns in a grid on the parent contact, account etc. form.

Well, you might ask, why not just sub-grid the underlying activity (let's assume emails) into the form directly using the standard approach. It's a good question and the solution will work... to an extent. The essential issue is that the "Closed Activities" is not related to the parent account in the standard parental-referential relationship. As I've explained previously, the activity is in fact related to the parent account not only via the Regarding attribute but also via the address fields (i.e. from, to, cc, bcc). So the only requirement for an email to rollup to a contact (or any other entity) is that the contact appear on any of the regarding, from, to, cc, bcc lines of the email. In short, the entity-activity relationship is multi-dimensional involving more than just one relationship.

Now going back to our solution above when you directly embed the emails directly on an entity form - well guess what? It's only going to relate to the parent entity via the standard regarding field. So simply put - if you have 5 emails on a contact, 2 of which are related via the "regarding" attribute and the other 3 that are related via one of the other from, to, cc, or bcc - while you will see all 5 emails in the Closed Activities, you will only see 2 of them in the sub-grid you just created. And therein lies the problem.

So in order to get around this we need to - you guessed it - use the embedded Advance Find grid approach. Fortunately, my previous post already walks through the example of embedding this on the contact form (but now we understand the tangible use case of that scenario). You can similarly embed this on the account form - in that case you will need to be sure to construct your initial Advanced Query to handle the rollup scenario (i.e. all contact emails rolling up to an account).

1 comment:

  1. Excellent article, thank you!

    A good view on the email history in Dynamics CRM is really missing.

    How can I write a FetchXML that rolls up all the various activities that are found in the "closed activity" list? There are a lot of emails which I would need to fetch together:
    - regardingobjectid is the Account
    - regardingobjectid is the Lead from which the account was created, an invoice related to the account, etc...
    - sender or torecipients is one of the contacts of the account OR the primary email address given at the account ...
    - etc.

    I see that CRMActivity.RollupRelatedByParty includes all of this and more.

    Is this actually possible? If yes, could you share the FetchXML?