• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Blog
  • Power Platform
    • Power Apps
    • Power Automate
    • Power BI
    • Power Virtual Agents
  • Dynamics 365
  • Azure
  • About Me
Joe Gill Logo

Joe Gill

Microsoft MVP - Power Platform Consultant

Home » Power Platform » Dynamics 365 » Your first Dynamics CRM WorkFlow Activity

Your first Dynamics CRM WorkFlow Activity

12th December 2008 by Joe Gill Leave a Comment

This post show should act as a guideline to creating you first workflow activity dll for Dynamics CRM. It includes some gotachas I came across so hopefully it will save you some time.

Create a new workflow activity library in Visual Studio

Your first Dynamics CRM WorkFlow Activity - Joe Gill

You need to reference the CRM Micrsoft.Crm.Sdk and , Micrsoft.Crm.Sdk.TypeProxy dlls in your project.

Your first Dynamics CRM WorkFlow Activity - Joe Gill

Rename the class to a suitable name and add the lines
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Crm.Workflow;

Add a decorator [CrmWorkflowActivity(“MyFirstWorkFlowActivity”, “ConcatStrings”)] to the class which will determine how it appears to the user in CRM and add the the method below

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) {return base.Execute(executionContext); }

Now sign the project at which point the bones of your workflow activity are in place.

Your first Dynamics CRM WorkFlow Activity - Joe Gill

In our example we will take two string parameters and and conconatate them into an ouput parameter add the code below. The decorator CrmInput and CrmOutput attributes determine which properties are visible in the CRM workflow editor. A property can be be set to both CrmInput and CrmOutput if required.

In our example we will take two string parameters and and conconatates them into an ouput parameter so add the code below

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
this.outString = this.inString1 + “, “+this.inString2 ;

return base.Execute(executionContext);
}

public static DependencyProperty inString1Property = DependencyProperty.Register(“inString1”, typeof(string), typeof(MyFirstCRMActivity));

[CrmInput(“InString1”)]

public string inString1
{
get { return (string)base.GetValue(inString1Property);}
set { base.SetValue(inString1Property, value);}
}

public static DependencyProperty inString2Property = DependencyProperty.Register(“inString2”, typeof(string), typeof(MyFirstCRMActivity));
[CrmInput(“InString2”)]

public string inString2
{
get { return (string)base.GetValue(inString2Property);}
set { base.SetValue(inString2Property, value); }
}

public static DependencyProperty outStringProperty = DependencyProperty.Register(“outString”, typeof(string), typeof(MyFirstCRMActivity));
[CrmOutput(“OutString”)]
public string outString
{
get { return (string)base.GetValue(outStringProperty);}
set { base.SetValue(outStringProperty, value); }
}

Build the project and copy the dll and pbl file to the C:Program FilesMicrosoft Dynamics CRM ServerServerbinassembly (assuming default install)

You now need to regsiter the DLL however do not use the registration tool that comes with the SDK use the version from
http://blogs.msdn.com/crm/archive/2008/02/04/crm-registering-plug-ins-made-easy.aspx

Your first Dynamics CRM WorkFlow Activity - Joe Gill

Once registered you can create a workflow in CRM which calls the new created dll
setting the input parameters in the first step and the output in the second

Your first Dynamics CRM WorkFlow Activity - Joe Gill

<

Your first Dynamics CRM WorkFlow Activity - Joe Gill

Gotchas – Here are a few problems you may come across

If you cannot publish your Workflow from CRM turn tracing on and check the trace logs

http://support.microsoft.com/kb/907490

Check if namespace and class the same as this will prevent the workflow from been published

ErrorCode: -2147201023 – the type in the dependency property is not correct

When redeploying you may need to stop and restart IIS and the CRM Asynch service so you can use a batch file or build script to execute the following
net stop w3svc
net start w3svc
net stop MSCRMAsyncService
net start MSCRMAsyncService

Another common problem

Could not create activity of type ‘CorrespondenceWorkflowActivity.Correspondence’. System.ArgumentException: Type ‘CorrespondenceWorkflowActivity.Correspondence’ does not define a static dependency property with name ‘inGuidProperty’.

http://blogs.catalystss.com/blogs/scott_seely/archive/2007/03/06/96.aspx

Share This On Social:
  • Tweet
  • Your first Dynamics CRM WorkFlow Activity - Joe Gill

Filed Under: .NET, Dynamics 365

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Popular Categories

  • Power Platform
    • Power Apps
    • Power Automate
    • Power Virtual Agents
  • Azure
    • Logic Apps
  • Dynamics 365
  • .NET
  • AI
  • SQL

More to See

Power Platform Requests – Base Request Capacity

17th December 2020 By Joe Gill

Power Automate Desktop

Power Automate Desktop – UI Flow

26th November 2020 By Joe Gill

Synapse Link for Dataverse – Metadata

5th July 2022 By Joe Gill

extract table from pdf and write as csv file using Power Automate Desktop

Extract Tables from a PDF using Power Automate Desktop

23rd May 2022 By Joe Gill

Tweets

Footer

Joe Gill

Microsoft Business Applications MVP – Power Platform, Dynamics 365 and Azure.

An architect with over twenty years experience designing and developing technology solutions. Specializing in the Microsoft technology stack including Power Platform, Dynamics 365 and Azure. Microsoft MVP Profile

Connect on Social

Useful Links

  • Home
  • Blog
  • About Joe Gill
  • Power Platform
  • Dynamics 365
  • Azure

Featured Posts

Power Platform Requests – Base Request Capacity

Power Automate Desktop – UI Flow

Power Fx Formula Columns in Dataverse

Synapse Link for Dataverse – Metadata

Extract Tables from a PDF using Power Automate Desktop

Dataverse Anonymization

© 2022 · Joe Gill