Dela via


Process classes, attributes, and types

 

Applies To: Dynamics CRM 2015

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

In This Topic

Process classes

Attributes and Microsoft Dynamics CRM types

InputAttribute and OutputAttribute

DefaultAttribute

ReferenceTargetAttribute

AttributeTargetAttribute

RequiredArgumentAttribute

Process classes

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 CRM, or in the XAML workflows. For detailed information about the process classes, see Microsoft.Xrm.Sdk.Workflow.

Attributes and Microsoft Dynamics CRM types

The Microsoft Dynamics CRM 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 CRM types in the custom workflow activities require you to specify additional attributes such as ReferenceTarget and AttributeTarget. These are described in the following section.

InputAttribute and OutputAttribute

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; }

DefaultAttribute

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.

Bool

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

DateTime

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

Decimal

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

Double

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

EntityReference

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

Int

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

Money

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

OptionSetValue

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

String

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

ReferenceTargetAttribute

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; }

AttributeTargetAttribute

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; }

RequiredArgumentAttribute

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; }

See Also

Custom workflow activities (workflow assemblies)
Add metadata to a custom workflow activity
Sample: Create a custom workflow activity

© 2016 Microsoft. All rights reserved. Copyright