Tag Cloud

CRM 2011 (161) CRM 4.0 (144) C# (116) JScript (109) Plugin (92) Registry (90) Techpedia (77) PyS60 (68) WScript (43) Plugin Message (31) Exploit (27) ShellCode (26) FAQ (22) JavaScript (21) Killer Codes (21) Hax (18) VB 6.0 (17) Commands (16) VBScript (16) Quotes (15) Turbo C++ (13) WMI (13) Security (11) 1337 (10) Tutorials (10) Asp.Net (9) Safe Boot (9) Python (8) Interview Questions (6) video (6) Ajax (5) VC++ (5) WebService (5) Workflow (5) Bat (4) Dorks (4) Sql Server (4) Aptitude (3) Picklist (3) Tweak (3) WCF (3) regex (3) Config (2) LINQ (2) PHP (2) Shell (2) Silverlight (2) TSql (2) flowchart (2) serialize (2) ASHX (1) CRM 4.0 Videos (1) Debug (1) FetchXml (1) GAC (1) General (1) Generics (1) HttpWebRequest (1) InputParameters (1) Lookup (1) Offline Plug-ins (1) OutputParameters (1) Plug-in Constructor (1) Protocol (1) RIA (1) Sharepoint (1) Walkthrough (1) Web.config (1) design patterns (1) generic (1) iframe (1) secure config (1) unsecure config (1) url (1)

Pages

Tuesday, March 26, 2013

Use of CRM Types in Custom Workflow Activity

The following sample shows how to use each of the types found in Microsoft Dynamics CRM.

Input Parameter: Number

Example


public static DependencyProperty myNumberProperty = DependencyProperty.Register("myNumber", typeof(CrmNumber), typeof(CreateCustomEntity));

[CrmInput("My Integer")]
public CrmNumber myNumber
{
get
{
return (CrmNumber)base.GetValue(myNumberProperty);
}
set
{
base.SetValue(myNumberProperty, value);
}
}


Input Parameter: String


Example



public static DependencyProperty myStringProperty = DependencyProperty.Register("myString", typeof(System.String), typeof(CreateCustomEntity));

[CrmInput("My String")]
public string myString
{
get
{
return (string)base.GetValue(myStringProperty);
}
set
{
base.SetValue(myStringProperty, value);
}
}


Input Parameter: Boolean


Example


public static DependencyProperty myBooleanProperty = DependencyProperty.Register("myBoolean", typeof(CrmBoolean), typeof(CreateCustomEntity));

[CrmInput("My Boolean")]
public CrmBoolean myBoolean
{
get
{
return (CrmBoolean)base.GetValue(myBooleanProperty);
}
set
{
base.SetValue(myBooleanProperty, value);
}
}


Input Parameter: Lookup


Example



public static DependencyProperty myLookupProperty = DependencyProperty.Register("myLookup", typeof(Lookup), typeof(CreateCustomEntity));

[CrmInput("My Lookup")]
[CrmReferenceTarget("account")]
public Lookup myLookup
{
get
{
return (Lookup)base.GetValue(myLookupProperty);
}
set
{
base.SetValue(myLookupProperty, value);
}
}


Input Parameter: Picklist


Example



public static DependencyProperty myPicklistProperty = DependencyProperty.Register("myPicklist", typeof(Picklist), typeof(CreateCustomEntity));

[CrmInput("My Picklist")]
[CrmAttributeTarget("account", "industrycode")]
public Picklist myPicklist
{
get
{
return (Picklist)base.GetValue(myPicklistProperty);
}
set
{
base.SetValue(myPicklistProperty, value);
}
}


Input Parameter: DateTime


Example



public static DependencyProperty myDateTimeProperty = DependencyProperty.Register("myDateTime", typeof(CrmDateTime), typeof(CreateCustomEntity));

[CrmInput("My DateTime")]
public CrmDateTime myDateTime
{
get
{
return (CrmDateTime)base.GetValue(myDateTimeProperty);
}
set
{
base.SetValue(myDateTimeProperty, value);
}
}


Input Parameter: Decimal


Example



public static DependencyProperty myDecimalProperty = DependencyProperty.Register("myDecimal", typeof(CrmDecimal), typeof(CreateCustomEntity));

[CrmInput("My Decimal")]
public CrmDecimal myDecimal
{
get
{
return (CrmDecimal)base.GetValue(myDecimalProperty);
}
set
{
base.SetValue(myDecimalProperty, value);
}
}


Input Parameter: Money


Example


public static DependencyProperty myMoneyProperty = DependencyProperty.Register("myMoney", typeof(CrmMoney), typeof(CreateCustomEntity));

[CrmInput("My Money")]
public CrmMoney myMoney
{
get
{
return (CrmMoney)base.GetValue(myMoneyProperty);
}
set
{
base.SetValue(myMoneyProperty, value);
}
}


Input Parameter: Float


Example


public static DependencyProperty myFloatProperty = DependencyProperty.Register("myFloat", typeof(CrmFloat), typeof(CreateCustomEntity));

[CrmInput("My Float")]
public CrmFloat myFloat
{
get
{
return (CrmFloat)base.GetValue(myFloatProperty);
}
set
{
base.SetValue(myFloatProperty, value);
}
}


Input Parameter: Status


Example


public static DependencyProperty myStatusProperty = DependencyProperty.Register("myStatus", typeof(Status), typeof(CreateCustomEntity));

[CrmInput("My Status")]
[CrmAttributeTarget("account", "statuscode")]
public Status myStatus
{
get
{
return (Status)base.GetValue(myStatusProperty);
}
set
{
base.SetValue(myStatusProperty, value);
}
}

Output Parameter: Lookup


Example


public static DependencyProperty myOutLookupProperty = DependencyProperty.Register("myOutLookup", typeof(Lookup), typeof(CreateCustomEntity));

[CrmOutput("My Output Lookup")]
[CrmReferenceTarget("new_customentity")]
public Lookup myOutLookup
{
get
{
return (Lookup)base.GetValue(myOutLookupProperty);
}
set
{
base.SetValue(myOutLookupProperty, value);
}
}

Execute Method: Using Types


Example


protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{

IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));
IWorkflowContext context = contextService.Context;

ICrmService crmService = (ICrmService)context.CreateCrmService();

DynamicEntity de = new DynamicEntity("new_customentity");

if (myBoolean != null)
{
de["new_boolean"] = myBoolean;
}
if (myDateTime != null)
{
de["new_datetime"] = myDateTime;
}
if (myDecimal != null)
{
de["new_decimal"] = myDecimal.Value.ToString();
}
if (myFloat != null)
{
de["new_float"] = myFloat;
}

if (myLookup != null)
{
de["new_lookup"] = myLookup;
}
if (myMoney != null)
{
de["new_money"] = myMoney;
}
if (myNumber != null)
{
de["new_number"] = myNumber;
}
if (myPicklist != null)
{
de["new_picklist"] = myPicklist;
}
if (myStatus != null)
{
de["new_status"] = myStatus.Value.ToString();
}
if (myString != null)
{
de["new_stringtext"] = myString;
de["new_memo"] = myString;
}

de["new_activationid"] = new Lookup(EntityName.workflow.ToString(),context.ActivationId);

myOutLookup = new Lookup("new_customentity", crmService.Create(de));
return ActivityExecutionStatus.Closed;
}

No comments: