Pages

Friday 12 July 2013

CRM 2011: Workflow Activity Input and Output Parameters & Data Types

Microsoft Dynamics CRM supports two types of parameters for a workflow activity.
  • Input Parameters
  • Output Parameters

Input Parameters

The input parameter is annotated with the .NET attribute "Input".


DefaultAttribute

DefaultAttribute class can be used to specify a default value (using "Default" attribute) for an input parameter. 


Bool

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


DateTime

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


Decimal

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


Double

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


Integer

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


Money (Currency)

[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; }
Attribute Target must specify the entity and attribute being referenced. 


String

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


Entity Reference

[Input("EntityReference input")]
[Output("EntityReference output")]
[ReferenceTarget("account")]
[Default("3B036E3E-94F9-DE11-B508-00155DBA2902", "account")]
public InOutArgument<EntityReference> AccountReference { get; set; }
Reference Target attribute must specify the type of entity being referenced. 


Required Argument Attribute 

System.Activities.RequiredArgumentAttribute class can be used to specify that the input parameter is required.

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


Output Parameters

The output parameter is annotated with the .NET attribute "Output"

//this is the name of the parameter that will be returned back to the workflow
[Output("Credit Score")]
//this line identifies the specific attribute which will be passed back to the workflow
[AttributeTarget(CustomEntity, "new_creditscore")]
//this line declares the output parameter and declares the proper data type of the parameter being passed back.
public OutArgument<int> CreditScore {get;set;}

Refer to Microsoft documentation for more details

No comments:

Post a Comment