Creating a no-code workflow for CRM 4.0 with Visual Studio 2005 (2008)

New in CRM 4.0 is the possibility to build custom workflows using Windows Workflow Foundation (WF). WF is the programming model, engine and tools for quickly building workflow enabled applications on CRM 4.0. In previous version of CRM the engine was limited and not as robust. WF is a standard component used in many other products (MOSS, Biztalk ect).

Business rule example
-when an Opportunity is created a check is done and if estimated value is greater than 100000 a task is created and associated to the opportunity. Schedule end date is set to same as opportunity estimated close date. No rocket science and just an example... I would like to see an example of integration with MOSS or other document library. Once I'm back from my parental leave and I have the time I might publish something.

Workflow from VS2005sp1
Flow from Visual Studio 2005 sp1.

In the workflow policy (TaskValues) I set the values for my reminder task and this is the only code needed.

this.ReminderTask = Microsoft.Crm.Workflow.CrmWorkflow.CreateEntity("task")
this.ReminderTask["subject"] = string.Concat("Please follow Up on Opportunity ", this.PostImageOpportunity["name"])
this.ReminderTask["scheduledend"] = this.PostImageOpportunity["estimatedclosedate"]
this.ReminderTask["description"] = "Automatic Task generated from Workflow. Please add your own notes here."

this.OpportunityId = Microsoft.Crm.SdkTypeProxy.CrmTypes.CreateLookup(Microsoft.Crm.SdkTypeProxy.EntityName.opportunity.ToString(),
this.Context.PrimaryEntityId)
this.ReminderTask["regardingobjectid"] = this.OpportunityId 

The final result on my Opportunity

Opportunity workflow runned

Click on the Activites I would see my "reminder task".
NOTE! Since the default view is on next 30days you need to change the view to "all" else you won't see you task.

Links related to subject

Windows Workflow Foundation on MSDN

https://msdn2.microsoft.com/en-us/netframework/aa663328.aspx

Dynamics on MSDN
https://msdn2.microsoft.com/sv-se/dynamics/default(en-us).aspx
SharePoint Server 2007 SDK: Software Development Kit
https://www.microsoft.com/downloads/details.aspx?familyid=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en
Windows SharePoint Services 3.0: Software Development Kit (SDK)
https://www.microsoft.com/downloads/details.aspx?familyid=19F21E5E-B715-4F0C-B959-8C6DCBDC1057&displaylang=en
VS 2005 extensions for .NET 3.0
https://www.microsoft.com/downloads/details.aspx?familyid=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=en
Microsoft .NET Framework 3.0 Redistributable Package
https://www.microsoft.com/downloads/details.aspx?familyid=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=en
Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation)
https://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=en
Microsoft Virtual Labs
https://netfx3.com/labs/

 

The Visual Studio project is attached below and for instructions how-to publish the workflow please see the CRM 4.0 SDK.

This posting is provided "AS IS" with no warranties, and confers no rights.

WfOpportunityReminder.zip

Comments

  • Anonymous
    January 21, 2008
    PingBack from http://www.travel-hilarity.com/travel_jones/?p=7860

  • Anonymous
    February 07, 2008
    Today I was at the Nacka Factory for the Swedish CRM 4.0 release party. Allot of customers, partners

  • Anonymous
    February 07, 2008
    Today I was at the Nacka Factory for the Swedish CRM 4.0 release party. Allot of customers, partners

  • Anonymous
    February 25, 2008
    There is a post that describes how to create a Custom Workflow and use it in Microsoft CRM 4.0 http:

  • Anonymous
    April 09, 2008
    ping back from http://www.castorsoft.com/articles/2008.1.22.htm

  • Anonymous
    September 27, 2010
    You can get the Great details about the CRM 2011 by using this Link www.dynamicsexchange.com/.../overview.aspx