Ms crm Form Scripting (Include external js file, like jquery. min. js)

Source: Internet
Author: User
function load_script(url) {    var x = new ActiveXObject("Msxml2.XMLHTTP");    x.open('GET', url, false); x.send('');    eval(x.responseText);}load_script("/isv/javascript/jquery.min.js");load_script("/isv/javascript/xx.js");

Reading function load_script is actually very simple. It is just a Javascript file loaded with ajax.

In fact, eval is used to execute external js Code.

This method causes code to be cached, and some people on the Internet have pointed out that eval is very inefficient: http://mscrm4ever.blogspot.com/2009/04/crm-form-script-loader.html

In fact, the cache is normal, which can avoid code loading every time, but it is slightly inconvenient during development.

We can solve the cache problem as follows:

load_script("/isv/javascript/xx.js?"+Math.random());

But remember to remove Math. random () after the development is complete ()

So how should I write in xx. js?

(Function () {// TODO}) (); // or (function ($) {// TODO}) (jQuery );

This code is also called JavaScript self-executed code.

----------------- Beautiful split line ---------------------

Get the lookup field in ms crm:

// Get the field that fired the event.var oField = event.srcElement;// Validate the field information.if (typeof(oField) != "undefined" && oField.DataValue != null){var dd = oField.DataValue;if(dd[0] != 'undefined'){  var id = dd[0].id;  //TODO   }}

Note that the retrieved DataValue is actually an Array (Array ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.