Freigeben über


Dynamics XRM Service Toolkit

 

This article is to publicise one interesting component in Dynamics CRM that probably not everybody is aware of. It is the XRMServiceToolkit

This is in essence a Javascript library that can help us do certain tasks more easily and quickly; for instance, tasks like CRUD (Create, Update, etc.) via REST and SOAP among other things.

It is important to note, that it is only available for CRM 2011, 2013 and 2015. You can use it for CRM 2016, by pointing to the old /XRMServices/2011/Organization.svc endpoint. The developers are considering extending the support to v2016, but a final decision hasn’t been made as of yet.

 

As an example of its usage, we can use this code to create a record:

var contact = {};

contact.FirstName = "Diane";

contact.LastName = "Morgan";

contact.MiddleName = "<&>";

contact.GenderCode = { Value: 2 };

contact.CreditLimit = { Value: "2.00" };

contact.BirthDate = birthDate;

contact.DoNotEMail = true;

contact.DoNotPhone = true;

XrmServiceToolkit.Rest.Create(

                contact,

                "ContactSet",

                function (result) {

                               contactId = result.ContactId;

                },

                function (error) {

                               alert(error.message);

                },

                false

);

 

As you can see, it reduces the length and complexity of the code that would be needed in case of not using the toolkit.

In order to use it, the following steps are needed:

  1. Download it from the site referenced above, and extract its contents.
  2. Create a new web resource in CRM called “JQuery”, Select the ‘Script(JScript)’ as the Type, and then browse for the jQuery.js file that you extracted.
  3. Create two more web resources called “json” and “XRMServiceToolKit”, by repeating the step ‘4’.
  4. Add all these web resources to a form in the following order:
    i. jQuery
    ii. jSon
    iii.XrmServiceToolkit
    iv.Your web resource library

 

Best Regards

EMEA Dynamics CRM Support Team

 

Share this Blog Article on Twitter

Tweet

Follow Us on Twitter

Follow @MSDynCRMSupport