Applies to Dynamics 365 for Customer Engagement apps version 9.x
Command bar (ribbon) commands
When you customize the Dynamics 365 for Customer Engagement command bar, you can configure commands for controls that you add. These commands contain rules that control whether the control is enabled and what action is performed when the control is used. For more information, see Customize commands and the ribbon.
Use of jQuery
Use jQuery with HTML web resources
We recommend that you use jQuery together with HTML web resources to provide user interfaces because it is an excellent cross-browser library.
With HTML web resources, you control the libraries that are present and there is no restriction against manipulating the DOM. Feel free to use jQuery within your HTML Web resources.
Because you don’t know what browser will be in use, you should make sure that any scripts that you use will work with all supported browsers. Most of the significant differences between Internet Explorer and other browser have to do with HTML and XML DOM manipulation. Because HTML DOM manipulation is not supported, if script logic is only performing supported actions and using the Client API, the changes required to support other browsers could be small.
A cross-browser library like jQuery is a good solution for developing web resources but should not be necessary for form scripts or ribbon commands. More information: Avoid using jQuery for form scripts
Avoid using unsupported methods
On the Internet, you can find many examples or suggestions that describe using unsupported methods. These may include leveraging undocumented internal function for page controls. These methods may work but because they are not supported you can’t expect that they will continue to work in future versions of Dynamics 365 for Customer Engagement.
Do not use jQuery for form script or commands
We do not recommend or support using jQuery for any pages within the application. This includes form scripts and ribbon commands. More information: Use of jQuery.
Recognize limitations for content delivery network (CDN) libraries
Some organizations will restrict Internet access for employees. Unless they configure the network to allow access to the CDN library sites, your code may fail for those organizations.
Use feature detection when writing functions for multiple browsers
Even when you use a cross-browser library like jQuery, you need to be very aware of differences between browsers. You can generally detect which browser is being used by querying the
navigator.useragent property. This is called browser detection. Browser detection is not a good strategy for most cases because it can’t take into account what features newer versions of a browser have. Also, some browsers provide the capability to modify the
navigation.useragent property so that they appear to be a different browser.
Feature detection is the recommended approach. By detecting what features are available, you can create code paths for the browsers you support without knowing exactly which browser is being used. For more information about feature detection, see How to Detect Features Instead of Browsers.
Do not access the DOM
window.getElementById method or the jQuery library. You are free to use these techniques in your HTML web resources, but they are not supported to access elements in Dynamics 365 for Customer Engagement application pages or entity forms. Instead, access to entity form elements are exposed through the Client API object model. The Dynamics 365 for Customer Engagement development team reserves the right to change how pages are composed, including the
ID values for elements, so using the Client API object model protects your code from changes in how pages are implemented.
Use asynchronous data access methods
When you access data by using the Dynamics 365 for Customer Engagement web services, always use an XMLHttpRequest that is configured to execute asynchronously. The reason is that the browser operates on a single thread. If that thread is being used to execute a long-running process synchronously the browser will stop responding.
Synchronous XMLHttpRequests are deprecated on the main thread of the browser because of the detrimental effects to the end user’s experience. Some browsers now provide a warning when this is detected. If browsers implement the specification at some time in the future an InvalidAccessError exception will be thrown. More information: http://www.w3.org/TR/XMLHttpRequest/#synchronous-flag and https://xhr.spec.whatwg.org/#the-open()-method
Write Client Application Extensions
Work with Customer Engagement data using web resources
Customize the Ribbon for Dynamics 365 for Customer Engagement apps
Web Resources for Dynamics 365 for Customer Engagement apps
Use the Web API with web resources
Understand the Client API Object Model