Showing posts with label Custom Activities/History tab. Show all posts
Showing posts with label Custom Activities/History tab. Show all posts

Wednesday, September 23, 2009

How to design a Custom Activities/History tab to show Activity Party information

There have often been requests for displaying the Activity Parties in the Activities/History tab of Account/Contact.

The details in these views are gathered from the ActivityPointer entity. The activity pointer entity is not customizable and so you are stuck with not having the activity party information like Sender/Receiver not being available for reference in the views.

However it is not that difficult to get a custom page to develop that does just this.

Let’s look at the various aspects related to this.

1. The Activities/History tab display not only activities directly associated with the account but also related entities of account.

How do we get this? The answer lies in the “TargetRollupActivityPointer” messages available in the SDK.

There are three different variation of this message available

· TargetRollupActivityPointerByAccount
· TargetRollupActivityPointerByContact
· TargetRollupActivityPointerByOpportunity

Searching the SDK for these messages should help you get you going with these messages.

// Create the target for the request.
TargetRollupActivityPointerByAccount target = new TargetRollupActivityPointerByAccount();
target.AccountId = new Guid("A0F87168-4B00-4CA2-925D-AA0A4C47B86F");

2. Get the Activity Parties Associated with these activities.

The information regarding the parties involved in an activity is not stored along with the activity but rather in a separate entity called activityparty.

You can query for activity party and search for activityid = activitypointer.activityid.

Note the result will return more than one records. This entity stores not just the sender/receiver but also the owner and organizer and such other activity party information. The participation type mask attribute describes the role of this party in the activity (search for activitypartytype in SDK for the entire list).

// Create the ConditionExpression.
ConditionExpression condition = new ConditionExpression();

// Set the ConditionExpressions Properties so that the condition is true
condition.AttributeName = "activityid";
condition.Operator = ConditionOperator.Equal
condition.Values = new string [] {activityid.ToString()};

// Set the properties of the QueryExpression
query.EntityName = EntityName.activityparty.ToString
query.ColumnSet = new AllColumns();

3. If you want to go further and be ambitious enough to add a column for displaying an attachment flag in case of emails with attachment.

CRM store the Email attachment information in the "activitymimeattachment" entity. You can filter this entity and look for activityid = activitypointer.activityid. If it returns any row it has attachments associated with it and you can add “true” flag for this.


// Create the ConditionExpression
ConditionExpression condition = new ConditionExpression

// Set the ConditionExpressions Properties so that the condition is true
condition.AttributeName = "activityid
condition.Operator = ConditionOperator.Equal
condition.Values = new string [] {emailId.ToString()};

// Set the properties of the QueryExpression
query .EntityName = EntityName. activitymimeattachment.ToString(); query.ColumnSet = new AllColumns();


Following the 3 – steps explained above you can get your custom page working the way you want.