Menu

Looking for the latest industry news and events?  Want to learn more about Microsoft Dynamics?  You've come to the right place!

Solving JQuery Issues in Microsoft Dynamics CRM Online 2015

With Microsoft Dynamics CRM Online 2015 Update 1, form scripts run in a different scope than the jQuery instance used by the application, hence, if you are expecting a JQuery instance in yourJQuery logo
form script, you will no longer get one, thus, the call to the jQuery $.ajax method will fail with an error “$ is undefined”

You would normally use jQuery on a CRM form for 2 reasons: manipulate the DOM, or make AJAX calls.  Since DOM manipulation is not supported, you would really only need jQuery if you were making AJAX calls.  You can avoid using jQuery to make AJAX calls by using the alternatives as described below:

  1. If you must use Jquery on a form, you can perform the following steps:
    1. Add jQuery library to the form properties
    2. Create a new alias to access jQuery instead of $. (e.g., $xyz)
    3. Declare the alias with jQuery.noConflict()
    4. An example of what this would look like is var $xyz = jQuery.noConflict(); 
    5. From this point on you can make Jquery calls using $xyz.ajax() within your code
  2. If you’re not using a third party tool or the SDK, you can directly use the XMLHTTPRequest object for AJAX calls.  Third party tools and the SDK are just wrappers around this object anyway.
  3. You can use the CRM SDK REST javascript library (SDK.REST.js) (as opposed to the Jquery version)
  4. We recommend using the XRMToolKit library instead, as this library uses the XMLHTTPRequest object, and also provides common functionality for accessing CRM
    1. Note:  XRMToolKit has methods that use Jquery, however these methods are in the “Extensions” namespace, and are “unsupported” as also declared in the toolkit

If you have other jQuery issues, please tell us what you encountered (and if/how you solved it) in the comments below. We may even use your feedback for a future blog post on this subject!


Tunc SamilogluWritten by Tunc Samiloglu
Principal Consultant/Architect, mcaConnect