Custom activities
Applies To: Dynamics CRM 2013
In Microsoft Dynamics CRM, you can create custom activities to support the communication needs of a business such as instant messaging (IM) and Short Message Service (SMS). To create a custom activity in CRM, create a custom entity, and specify it as an activity entity using the EntityMetadata.IsActivity property.
However, unlike other custom entities, you can’t specify a primary attribute for a custom activity because, by default, each custom activity must have a primary attribute named ”Subject”.
When you create a custom activity entity, all the properties and privileges of the activitypointer entity are inherited for the custom activity. Further, all the activity party types become available for the custom activity, and as a result the corresponding properties are also inherited.
You can create 1-to-Many (1:N) relationships for a custom activity just like any other activity, and also update the existing relationships.
Privileges and access rights
You require the same set of CRM privileges and access rights to work with custom activities as those required to work with custom entities. For more information about custom entities, see Customize entity metadata.
Creating a custom activity
To create a custom activity entity, set the values of the properties listed in the following table.
Property name |
Value |
Notes |
---|---|---|
true |
Specify the custom entity as an activity entity. |
|
true |
A custom activity entity must have offline availability. |
|
false |
A custom activity entity cannot have mail merge enabled. |
|
OwnershipTypes. TeamOwned |
A custom activity entity can be either team-owned or user-owned. |
|
0 - None |
(Optional) Specify whether a custom activity should appear in the activity menus in the web application.
If you do not specify this property, the custom activity is created with the default property value: 1. That is, the custom activity is available in the activity menus. Moreover, ActivityTypeMask can be set at the activity creation time only, and once set, cannot be modified. |
|
false |
A custom activity entity must not have a relationship with activities. |
|
true |
A custom activity entity must have a relationship to notes. |
|
SchemaName is “Subject”. |
The schema name of the PrimaryAttribute for all activities must be “Subject”. |
Example
The following sample shows how you can create a custom activity by using the Microsoft Dynamics CRM SDK.
String prefix = "new_";
String customEntityName = prefix + "instantmessage";
// Create the custom activity entity.
CreateEntityRequest request = new CreateEntityRequest
{
HasNotes = true,
HasActivities = false,
PrimaryAttribute = new StringAttributeMetadata
{
SchemaName = "Subject",
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
MaxLength = 100,
DisplayName = new Label("Subject", 1033)
},
Entity = new EntityMetadata
{
IsActivity = true,
SchemaName = customEntityName,
DisplayName = new Label("Instant Message", 1033),
DisplayCollectionName = new Label("Instant Messages", 1033),
OwnershipType = OwnershipTypes.UserOwned,
IsAvailableOffline = true,
}
};
_serviceProxy.Execute(request);
//Entity must be published
See Also
Activity entities
ActivityPointer (activity) entity
Sample: Create a custom activity
Sample: Create and update entity metadata