The Microsoft Dynamics CRM Blog
News and views from the Microsoft Dynamics CRM Team

Extending Microsoft Dynamics CRM 3.0 - Redux

Extending Microsoft Dynamics CRM 3.0 - Redux

  • Comments 3

Often new Microsoft Dynamics CRM customers and partners ask, “Can we extend this product's functionality?” Usually this is quickly followed by the question, “How can we do it?” This post is intended to provide brief answers to these questions. And of course, as everybody familiar with Microsoft Dynamics CRM 3.0 knows, the answer to the first question is a resounding YES!

Microsoft Dynamics CRM provides several ways to extend its out-of-the-box functionality. We can personalize our interface in several ways. For example we can create client-side code that will be run when opening a form. We can create and customize workflow rules that will raise actions when some events occur. Or we could build our own assemblies and .Net code that will manipulate our CRM data.

To access this data we do not need to connect directly to the CRM database, because CRM provides us with a very powerful Web service that gives us access to most the data in our database in a strong typed format.

In other words: You can do programmatically almost any action that a user could do with his keyboard and his mouse. This is really powerful because we can migrate the contents of our old database into our brand new CRM system by simply coding a loop that follows all the files in our old database and then calls the Create method of the CRM service to create the objects in the new database.

You can imagine the possibilities that this can give you when integrating CRM with your other applications. This Web service ensures that almost everything that you can do with .net, you can apply it to CRM. For example, in the last months I’ve been in contact with customers who have implemented their own integration with their telephone systems, or even synchronization with the databases of third-party products.

The first thing you have to have is a testing CRM server. If you are reading this blog probably you already have one. If you do not maybe this is the time to get one of the virtual computers that contains CRM that can be found in the net.

Once you have CRM working and you have a valid user to access it, you need a programming environment or platform. We recommend Microsoft Visual Studio 2003 on a computer with a connection to the CRM Server:

1. Open Microsoft Visual Studio 2003. From the File menu select New,  Project, Visual C# Projects, and Windows Application.

2. In the field ‘Name’ type a name for the project (for example ‘SDKexample’) and press OK.

3. As soon as the project is created, you will see an empty form. Add to it one button and one text box by drag it from the Toolbox panel which is at the left of the screen. In case the Toolbox panel is not visible by default, you can enable it in the View menu by selecting Toolbox.

4. Put the button and the text box one above the other in the middle on the form. Then, double-click the button.

5. The code window will open.

6. In the right side panel, right-click the project name (in this example ‘SDKexample’) and then click "add Web Reference".

7. In the dialog form that has just open type this in the URL field: http://<servername:port>/msCRMservices/2006/CRMservice.asmx where <servername> and < port> are placeholders for your actual data (such as CRMserver:5555)

8. Click GO. The right side panel will show ‘1 Service Found’. Under ‘Web reference name’ type ‘CRMSdk’ and then click Add Reference.

9. Going back to the code, near the top of the code window, under the lines that begins with "using" type: ‘using <projectname>.CRMSdk;’ where the project name is the actual name of the project (For Example In this case: using Example.CRMSdk;).

10. Now locate this text within the code. It should be near the end of the code:

private void button1_Click(object sender, System.EventArgs e)

  {

   }

11. Replace those lines with this code. The result after you run the code and pushing the button will be a new phone call created in the CRMsystem.

private void button1_Click(object sender, System.EventArgs e)

     {

        CrmService service = new CrmService();

        service.Credentials = System.Net.CredentialCache.DefaultCredentials;

        phonecall p = new phonecall();

        p.subject = "Test";

        CrmBoolean b = new CrmBoolean();

b.Value = true;

        p.isbilled = b;

        try

        {

          service.Create(p);

          textBox1.Text = "Task created";

        }

        catch (System.Web.Services.Protocols.SoapException ex)

        {

          textBox1.Text = ex.Detail.InnerText;

        }

     }

12. Press F5 and the application should be opened. Remember that the user pushing the button needs to be a valid user for Microsoft CRM. This means that you can only start this application if you already can use normally the CRM Web interface.

If everything has gone well, now you should have a new phone call activity in your CRM workplace. Easy, isn’t it?

Of course this is a very simple sample, but I think that you can set this code to be executed automatically when a new e-mail arrives, or when a case is created inside CRM. If you really like this stuff, maybe you want to go through the SDK documentation to discover all the possibilities that this Web service offers you.

You can find this documentation here:

http://www.microsoft.com/downloads/details.aspx?familyid=9C178B68-3A06-4898-BC83-BD14B74308C5&displaylang=en

Once you install this, do not expect any application installed under your ‘All programs’ section. This install will create the SDK user files in the destination folder that you have chosen. If you go there, open the file ‘CRMsdk3_0.chm’ and you will get the documentation on screen. Then push the Search button in the upper-left corner. There type ‘phone call’ and press enter, and you will retrieve a big list that uses all the entries which contain the word ‘phone call’ (with the object constructor, samples, related entities, and related documentation).

Note: You can also access this SDK online at the Microsoft Dynamics CRM Developer Center without an install.

Additionally, inside the folder in which SDK has been installed, you will find a folder named ‘SDK samples’, that contain some examples exactly like the one I’ve written above. These samples go together with a readme file that describes the steps to make the sample run. I’m sure that with these samples and the documentation you will get great things alive.

Luis Mazario Torres

Page 1 of 1 (3 items)
Leave a Comment
  • Please add 3 and 3 and type the answer here:
  • Post