Just a few reasons why jQuery is so useful with CRM 4.0
I will be updating the post as I find some useful scripts in jQuery while working with CRM 4.0.
Okay, so here goes…
Loading jQuery from _customscripts:
function load_script(url)
{
var x = new ActiveXObject("Msxml2.XMLHTTP");
x.open('GET', url, false); x.send('');
eval(x.responseText);
var s = x.responseText.split(/\n/);
var r = /^function\s*([a-z_]+)/i;
for (var i = 0; i < s.length; i++) {
var m = r.exec(s[i]);
if (m != null)
window[m[1]] = eval(m[1]);
}
}
//usage: normally on the page's onLoad() event
load_script("/_customscripts/jquery-1.3.2.min.js");
Cross page scripting:
//Old school jscripting:
crmForm.all.IFRAME_TOBULKMATCH.contentWindow.document.all.testval.value = crmVal;
//jQuery
$('#IFRAME_TOBULKMATCH').contents().find('testval').val(crmVal);
Need to get hold of the oid attribute value commonly found when you add a lookup field on your form sitting inside the span element?
//jQuery
var entId = $('.ms-crm-Lookup-Item').attr('oid');
Looping through the result in the Advanced Find grid is so easy with jQuery:
//jQuery
$('#' + iframe).contents().find('#gridBodyTable tr').each(function()
{
var v_oid = this.oid;
if (this.selected == true)
{
counter++;
//Do whatever you need to do here
}
});
Get hold of a specific xml element returned by one of the value attributes normally found in the crmFormSubmitMappedDataRemainder element in CRM 4.0:
//jQuery
var myVal = $($("#crmFormSubmitMappedDataRemainder")
.val()).filter("xyz_myguidval").text()
Filed under C#, CRM, JavaScript, jQuery.
Leave a Comment