简体   繁体   English

您如何在Dynamics CRM 2011中拥有多个JavaScript库

[英]How do you have multiple javascript libraries in Dynamics CRM 2011

Right I am creating a method which adds an Account to Dynamics CRM with an Ajax POST to a built in webservice, the code is as follows : 我正在创建一个方法,通过Ajax POST向Dynamics CRM添加一个帐户到内置的Web服务,代码如下:

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) { }
});

Right this code has a link to JSON and JQuery libraries, how do i link them in dynamic CRM 2011. 这段代码有一个指向JSON和JQuery库的链接,我如何在动态CRM 2011中链接它们。

I am looking to execute the code on a onload function to add the new account. 我希望在onload函数上执行代码来添加新帐户。 But am in the dark at the moment to how that will work. 但是,目前我处于黑暗中将如何发挥作用。

I understand I have to first: 我明白我必须先:

  • Go to web resources 转到网络资源
  • Add the above jquery 添加上面的jquery
  • save the file 保存文件
  • Go to my entity and add the javascript library and its method to call on the onload 转到我的实体并添加javascript库及其方法来调用onload

but it links to json and jquery libraries though. 但它链接到json和jquery库。 How does this work? 这是如何运作的?

Just upload those libraries as additional Web Resources. 只需将这些库上传为其他Web资源。 On the customizations for the form, you can choose which libraries get loaded on the form. 在表单的自定义上,您可以选择在表单上加载哪些库。 Just make sure your JSON and jQuery libraries are loaded before your custom code, and you should be fine. 只需确保在自定义代码之前加载JSON和jQuery库,您应该没问题。

Make sure all other depending JavaScipt libraries are loaded before this javascipt and you have to maintain the depending javascript precedence. 确保在此javascipt之前加载所有其他依赖JavaScipt库,并且必须维护依赖的javascript优先级。 Since you are using Json and JQuery libraries you have to load those libaries first. 由于您使用的是Json和JQuery库,因此必须先加载这些库。 Also if you are using any function of some other library it has to be loaded (it should be in the top of the list) before this javascript. 此外,如果你使用其他库的任何功能,它必须在此javascript之前加载(它应该在列表的顶部)。

使用像Jingo.js这样的JS Package / Dependency管理器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM