Welcome to MSDN Blogs Sign in | Join | Help

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
http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx
Dynamics on MSDN
http://msdn2.microsoft.com/sv-se/dynamics/default(en-us).aspx
SharePoint Server 2007 SDK: Software Development Kit
http://www.microsoft.com/downloads/details.aspx?familyid=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en
Windows SharePoint Services 3.0: Software Development Kit (SDK)
http://www.microsoft.com/downloads/details.aspx?familyid=19F21E5E-B715-4F0C-B959-8C6DCBDC1057&displaylang=en
VS 2005 extensions for .NET 3.0
http://www.microsoft.com/downloads/details.aspx?familyid=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=en
Microsoft .NET Framework 3.0 Redistributable Package
http://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)
http://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=en
Microsoft Virtual Labs
http://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.

Published Monday, January 21, 2008 9:29 PM by Jonas Deibe
Filed under: , , ,

Attachment(s): WfOpportunityReminder.zip

Comments

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

# Blog corner report from the Swedish CRM 4.0 release

Today I was at the Nacka Factory for the Swedish CRM 4.0 release party. Allot of customers, partners

Thursday, February 07, 2008 3:31 PM by Jonas Deibe - Dynamics CRM, C#, JS

# Blog corner report from the Swedish CRM 4.0 release

Today I was at the Nacka Factory for the Swedish CRM 4.0 release party. Allot of customers, partners

Thursday, February 07, 2008 3:40 PM by Noticias externas

# When It's the time to create more than a simple workflow

There is a post that describes how to create a Custom Workflow and use it in Microsoft CRM 4.0 http:

Monday, February 25, 2008 4:01 PM by Frederick Chapleau CRM weBlog

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

Wednesday, April 09, 2008 10:56 PM by CastorSolutions
Anonymous comments are disabled
 
Page view tracker