Destination .NET! Platform Tools, Technologies & Resources
1 3 5 7 9
2 4 6 8 10
From VB4, C++ and Java to working on .Net Since Beta, 1.0.
Improving partner satisfaction and accelerating Microsoft platform adoption for managed ISVs.
Is your application compatible with Windows Vista? Make sure today by taking our self-test. Just follow the five steps of the Works with Windows Vista program so that you and your customers can be confident in your solution’s compatibility. Read More >>
What product/topic are you most interested in?
(Choose your top answer.)
Windows Vista
Windows Server 2008
2007 Microsoft Office system
SQL Server 2008
ASP.NET
Visual Studio 2008
Windows Mobile
Software as a Service
A little bit of everything
Just browsing, thanks

View Results
Whether you love the site or hate it, we want to know. Tell us what topics to cover, help us improve things, or just sound off on something we could've done better. Send your feedback directly to the editor by email.
 Print Print
Rate this item | 0 users have rated this item.
CRM Development—The Easy Way (cont'd)

Peek Under the Hood
A picture is worth a thousand words, but to developers a code sample is clearer than both. In this simple C# example we'll show how Microsoft Dynamics CRM could take an incoming fax and convert it to a Follow-up Task with a due date a week after it was received.

using System;
using Microsoft.Crm.Sdk.Utility;
using CrmSdk;

namespace Microsoft.Crm.Sdk.HowTo
{
   /// <summary>
   /// This sample shows how to convert a fax into a task.
   /// </summary>
   public class ConvertFaxToTask
   {
      static void Main(string[] args)
      {
         ConvertFaxToTask.Run("http://localhost:5555", "CRM_SDK");
      }

      public static bool Run(string crmServerUrl, string orgName)
      {
         #region Setup Data Required for this Sample

         bool success = false;

         #endregion

         try
         {
            // Set up the CRM Service.
            CrmService service = CrmServiceUtility.GetCrmService
            (crmServerUrl, orgName);
            service.PreAuthenticate = true;
            
            // Get the current user.
            WhoAmIRequest userRequest = new WhoAmIRequest();
            WhoAmIResponse user = (WhoAmIResponse)service.Execute(userRequest);

            // Create the fax object.
            fax fax = new fax();

            // Set the properties of the fax.
            fax.subject = "Test Fax";
            fax.description = "New Fax";

            // Create the party sending and receiving the fax.
            activityparty party = new activityparty();

            // Set the properties of Activityparty.
            party.partyid = new Lookup();
            party.partyid.type = EntityName.systemuser.ToString();
            party.partyid.Value = user.UserId;

            // The party sends and receives the fax.
            fax.from = new activityparty[] { party };
            fax.to = new activityparty[] { party };

            // Create the fax.
            Guid createdFaxId = service.Create(fax);

            // Retrieve the created fax.
            fax newFax = (fax)service.Retrieve(EntityName.fax.ToString(), 
            createdFaxId, new AllColumns());

            // Create the task object.
            task task = new task();

            // Set the properties of the task.
            task.subject = "Follow Up: " + newFax.subject;

            // Due date of the task.
            task.scheduledend = new CrmDateTime();

            // Get the date that the fax was received.
            DateTime endDate = DateTime.Parse(newFax.createdon.date);

            // Add one week to get the date that the task is due.
            endDate = endDate.AddDays(7);

            // Set the due date of the task.
            task.scheduledend.Value = endDate.ToString();

            // Create the task.
            Guid createdTaskId = service.Create(task);

            #region check success

            if (createdTaskId != Guid.Empty)
            {
               success = true;
            }

            #endregion

            #region Remove Data Required for this Sample

            service.Delete(EntityName.fax.ToString(), createdFaxId);
            service.Delete(EntityName.task.ToString(), createdTaskId);

            #endregion
         }
         catch (System.Web.Services.Protocols.SoapException)
         {
            // Add your error handling code here.
         }

         return success;
      }
   }
}
That's all there is to it. You've just created a useful feature that would take a whole lot of code to implement outside of Microsoft Dynamics CRM. You also don't need to write the code to manage tasks (assign them to other users, delete them, update them, include them in the workflow, and so on), it's all done for you by the underlying Microsoft Dynamics CRM platform.

What Are You Waiting For?
Microsoft Dynamics CRM 4.0 is clearly a solution that CRM developers (and those responsible for CRM initiatives) should seriously investigate. It brings rapid development to CRM so you can get to market faster and at a lower cost. Be sure to download the Dynamics CRM 4.0 SDK to learn all about creating plug-ins, working with custom workflow activities, using the new Web services and data management features, and much more. The code samples, step-by-step learning materials, and detailed reference guide show just how easy it is to integrate your applications with the platform. Those looking for a first hand overview of Microsoft Dynamics CRM 4.0 should plan to attend one of the upcoming Microsoft Dynamics CRM 4.0 Launch Events and Microsoft Dynamics™ Discovery Day Roadshows.

* This article was commissioned by and prepared for Microsoft Corporation. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


Page 2 of 2
Allan McNaughton, a veteran developer and long-time writer, is the principal at Technical Insight LLC, a firm specializing in the composition of high-technology whitepapers.
Previous Page: Next Generation CRM  
Page 1: Next Generation CRMPage 2: Peek Under the Hood
Submit article to:
Extending your solution to run on Microsoft technology is easier than ever. Through NXT, you can reach more customers, increase revenues and slash development time and costs, accelerating both your time to market and profitability. Get the details on NTX. >>
Sign up for your free e-mail newsletters today!
DevX Windows Developer Update

More Newsletters
Taming Trees: Building Branching Structures
Implement Drag and Drop in Your Windows Forms Applications
Performing CRUD and Grouping Operations with the LinqDataSource Control
Override a Child Class' Parent Method
Keeping Your Directory Structure Intact After Deleting Folder Contents



JupiterOnlineMedia

internet.com earthweb.com Devx.com mediabistro.com Graphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers