Process classes, attributes, and types

 

Updated: November 29, 2016

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

This topic provides information about the process classes and types found in Microsoft Dynamics 365 that you can use to work with the custom activities.

The process classes are available in the Microsoft.Xrm.Sdk.Workflow namespace (Microsoft.Xrm.Sdk.Workflow.dll). You can use these classes to create custom activities in Windows Workflow Foundation, and then use the activities in the Processes area of Microsoft Dynamics 365, or in the XAML workflows. For detailed information about the process classes, see Microsoft.Xrm.Sdk.Workflow.

The Microsoft Dynamics 365 types are found in the Microsoft.Xrm.Sdk namespace (Microsoft.Xrm.Sdk.dll). Use the InputAttribute and OutputAttribute classes to annotate input and output properties.

The following types are supported for custom workflow activities:

Apart from the Input, Output, and Default attributes, some of the supported Microsoft Dynamics 365 types in the custom workflow activities require you to specify additional attributes such as ReferenceTarget and AttributeTarget. These are described in the following section.

The following sample shows how to add the input and output attributes to a Money parameter used in a custom workflow activity. It also shows how to specify a default value for the property.

[Input("Money input")]
[Output("Money output")]
[Default("232.3")]
public InOutArgument<Money> MoneyParameter { get; set; }

You can use the DefaultAttribute class to specify a default value for an input parameter. The following examples show how to set the default value for each type using the Default attribute.

[Input("Bool input")]
[Output("Bool output")]
[Default("True")]
public InOutArgument<bool> Bool { get; set; }

[Input("DateTime input")]
[Output("DateTime output")]
[Default("2004-07-09T02:54:00Z")]
public InOutArgument<DateTime> DateTime { get; set; }

[Input("Decimal input")]
[Output("Decimal output")]
[Default("23.45")]
public InOutArgument<decimal> Decimal { get; set; }

[Input("Double input")]
[Output("Double output")]
[Default("252.2")]
public InOutArgument<double> Double { get; set; }

[Input("EntityReference input")]
[Output("EntityReference output")]
[ReferenceTarget("account")]
[Default("3B036E3E-94F9-DE11-B508-00155DBA2902", "account")]
public InOutArgument<EntityReference> EntityReference { get; set; }

[Input("Int input")]
[Output("Int output")]
[Default("2322")]
public InOutArgument<int> Int { get; set; }

[Input("Money input")]
[Output("Money output")]
[Default("232.3")]
public InOutArgument<Money> Money { get; set; }

[Input("OptionSetValue input")]
[Output("OptionSetValue output")]
[AttributeTarget("account", "industrycode")]
[Default("3")]
public InOutArgument<OptionSetValue> OptionSetValue { get; set; }

[Input("String input")]
[Output("String output")]
[Default("string default")]
public InOutArgument<string> String { get; set; }

The EntityReference attribute type requires you to specify the entity type being referenced using the ReferenceTargetAttribute class. The following sample shows how to add the input and output attributes to an AccountReference parameter in a custom workflow activity by using the ReferenceTarget attribute.

[Input("EntityReference input")]
[Output("EntityReference output")]
[ReferenceTarget("account")]
[Default("3B036E3E-94F9-DE11-B508-00155DBA2902", "account")]
public InOutArgument<EntityReference> AccountReference { get; set; }

The OptionSetValue attribute type requires you to specify the entity and the attribute being referenced using the AttributeTargetAttribute class. The following sample shows how to add the input and output attributes to an OptionSetValue parameter in a custom workflow activity by using the AttributeTarget attribute.

[Input("OptionSetValue input")]
[Output("OptionSetValue output")]
[AttributeTarget("account", "industrycode")]
[Default("3")]
public InOutArgument<OptionSetValue> OptionSetValue { get; set; }

You can use the System.Activities.RequiredArgumentAttribute class to specify that an input parameter is required.

[RequiredArgument]
[Input("Update Next Birthdate for")]
[ReferenceTarget("contact")]
public InArgument<EntityReference> Contact { get; set; }

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright

Community Additions

Show: