How do you have multiple javascript libraries in Dynamics CRM 2011

Correctly I am creating a method that adds a Dynamics CRM account using Ajax POST to the embedded web service, the code is as follows:

var context = GetGlobalContext(); var serverUrl = context.getServerUrl(); var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc"; var account = new Object(); account.Name = "Sample Account created via OData jQuery library."; // Parse the entity object into JSON var jsonEntity = window.JSON.stringify(account); // Asynchronous AJAX function to Create a CRM record using OData $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", datatype: "json", url: serverUrl + ODATA_ENDPOINT + "/AccountSet", data: jsonEntity, beforeSend: function (XMLHttpRequest) { //Specifying this header ensures that the results will be returned as JSON. XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, success: function (data, textStatus, XmlHttpRequest) { }, error: function (XMLHttpRequest, textStatus, errorThrown) { } }); 

On the right, this code has a link to the JSON and JQuery libraries, how can I link them in dynamic CRM 2011.

I want to execute the code in the onload function to add a new account. But right now I'm in the dark how this will work.

I understand that I must first:

  • Go to web resources
  • Add the above jquery
  • save file
  • Go to my entity and add the javascript library and its method to call onload

but it references json and jquery libraries. How it works?

+4
source share
3 answers

Just download these libraries as additional web resources. In the form settings, you can choose which libraries to load into the form. Just make sure your JSON and jQuery libraries are loaded up to your custom code and everything will be fine.

+7
source

Make sure all other JavaScipt libraries are loaded prior to this javascipt, and you need to maintain javascript-specific priority. Since you are using the Json and JQuery libraries, you need to download these libraries first. Also, if you use any function of any other library, it must be loaded (it must be at the top of the list) before this javascript.

+1
source

Use a JS / Dependency package manager like Jingo.js

0
source

Source: https://habr.com/ru/post/1339675/


All Articles