Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 2011 - JavaScript... global variables... sort of.

$
0
0

I've notice that in the CRM form customizations the JavaScript never users a varible to hold the name of the field.  Maybe something like...

var firstnameField = "firstname";
var middlenameField = "middlename";
var lastnameField = "lastname";

function....
{
     Xrm.Page.getAttribute(firstnameFiled).getvalue();
}

function....
{
     Xrm.Page.getAttribute(firstnameFiled).getvalue();
}

function....
{
     Xrm.Page.getAttribute(firstnameFiled).getvalue();
}

Why is this?  Can we just use a a closure to get this to work as expected?  I have hundreds of lines of JavaScript code that deals with this sort of thing and it really sucks to have to go back through it and rename a field in dozens of places.  I figure there must be a reason for not doing this.  I have noticed that on some of the SDK functions using a string works and others it does not.  Does anyone know what that is?

Any thoughts about how to best deal with this?  I have set it up using a closure and it works fine, but later I removed it in fear of something I don't know about. 


Jon Gregory Rothlander



Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>