Custom activities

 

Updated: November 29, 2016

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

In Microsoft Dynamics 365, 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 Dynamics 365, 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.

You require the same set of Dynamics 365 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.

To create a custom activity entity, set the values of the properties listed in the following table.

Property name

Value

Notes

EntityMetadata.IsActivity

true

Specify the custom entity as an activity entity.

EntityMetadata.IsAvailableOffline

true

A custom activity entity must have offline availability.

EntityMetadata.IsMailMergeEnabled

false

A custom activity entity cannot have mail merge enabled.

EntityMetadata.OwnershipType

OwnershipTypes. TeamOwned
or
OwnershipTypes. UserOwned

A custom activity entity can be either team-owned or user-owned.

EntityMetadata.ActivityTypeMask

0 - None
or
1 – Communication Activity

(Optional) Specify whether a custom activity should appear in the activity menus in the web application.

  • Specify 0 (None) to hide it from appearing in the activity menus. The custom activity will appear in the associated grids of only those entities with which it is associated (has relationship).

  • Specify 1 (Communication Activity) to make it appear in the activity menus.

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.

CreateEntityRequest.HasActivities

false

A custom activity entity must not have a relationship with activities.

CreateEntityRequest.HasNotes

true

A custom activity entity must have a relationship to notes.

CreateEntityRequest. PrimaryAttribute

SchemaName is “Subject”.

The schema name of the PrimaryAttribute for all activities must be “Subject”.

The following sample shows how you can create a custom activity by using the Microsoft Dynamics 365 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

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright

Community Additions

ADD
Show: