Interacting with parent controls in Microsoft Dynamics CRM 4.0.

0 points

In case you do a seek in Google at the identify above, you’ll find plenty of code samples of the javascript to get and set the values of controls on CRM 4.zero forms and even how to do it from an IFRAME in a web page. As you may recognize when you have any revel in of extending MS CRM four.zero, the IFRAME is a large part of offering more capability to customers.

Of path, as you may realize if you have a bit of a records in internet UI layout, there are a few hurdles with the intention to be allowed to run javascript in case your IFRAME contains a web page from a site that is exceptional to the HTML web page hosting the IFRAME. This so-called pass website online scripting become a large trouble in earlier browsers and security blocks brought in to stop this being hijacked for nefarious purposes. To address this the form dressmaker in CRM four.0 has the choice to switch this safety on or off. sadly this has its limitations and i found that the option did no longer have any impact on the script i was seeking to run from the web page inside the IFRAME. in the end I had to create a virtual listing in IIS in the equal internet site as CRM. the other part I had to observe for is that I used the URL from the foundation of the web page, no longer the redirected route that the CRM application uses.

As soon as over that hurdle, I had a chunk of a battle with Javascript and dragging it out of my mind on the identical time! To provide an explanation for what i used to be looking to do, I had two controls on the figure form to populate. No problem, I had the names of the attributes and Microsoft Dynamics CRM 4.0 has a nice manner of naming fields and controls from the characteristic names. lamentably I were given an get entry to denied errors thrown by means of the script engine within the browser. by a procedure of trial and error I mounted that one manage labored and the other did no longer. not because of cost types or anything, it became due to the fact one became a lookup and the alternative changed into a straight text subject. Lookups need a specific technique to gaining access to them, as they use an array as part of the matching to listing setup.

Having established this, I dived in to the code inside the Microsoft Dynamics CRM 4.0 SDK that is something like thus :

//Create an array to set as the DataValue for the lookup control.

var lookupData = new Array();

//Create an object upload to the array.

   var lookupItem= new item();

//Set the id, typename, and name properties to the item.

   lookupItem.identity = ‘{1AAC1363-01A1-DB11-8432-0003FF9CE217}’;

   lookupItem.typename = ‘account’;

   lookupItem.name = ‘a motorcycle shop’;

// add the item to the array.

   lookupData[0] = lookupItem;

// Set the value of the research subject to the value of the array.

   crmForm.all.parentaccountid.DataValue = lookupData;

pleasant, however what guid id is that and how changed into I going to find it out. further searching set up that it is the guid of the entity that is listed by means of the research. locating this out was a chunk of a hunt again. first off i found the call of the entity being looked up with the aid of checking the houses of the research at the determine shape. This pointed me to the source entity. Then I navigated thru settings to call up the entity. Doing this coated up a URL with the GUID on it – best. The typename changed into additionally shown on the sort of property pages. I filled them all in, and it didn’t paintings. I did some cursing of Javascript and started searching again.

I subsequently ended up wandering the directories of the SDK again. in case you browse down the folders clienthowtousinglookups there are two script documents readvaluelookupcontrol.js and setvaluelookupcontrol.js. I opened up the latter and it has the following code:

// Create a lookupItem to store the values which you want to set to a goal lookup control.

var lookupItem = new Array();

// Specify the values on the signature of LookupControlItem. these values are the GUID of pricelevel, the type code of pricelevel, and the call of the research cost.

lookupItem[0] = new LookupControlItem (“{F31BB38A-0EC0-403F-99A6-3AF469D7D76E”}, 1022, “Retail”);

// Set the form control value to the lookupItem which you simply created.

crmForm.all.pricelevelid.DataValue = lookupItem ;

Adequate excellent, however the realisation dawned slowly that the second one line of code changed into calling a characteristic I hadn’t seen thus far. i was correct, after performing some more Google paintings to set up this. similarly looking discovered that this is a feature used by the CRM utility itself. if you cross hunting in Inetpub, you will discover the record that defines the characteristic. test the file research.js which you’ll locate below the net root in _static_controlslookup . In there is the definition of LookupControlItem as a result:

Feature LookupControlItem(sId, iType, sName, sOnclick, sDisplayClass, sData, sTypeName, iCategory, sAmbiguousRecordsXml)

{

this.id = sId;

this.kind = iType;

this.call = sName;

this.onclick = sOnclick;

this.displayClass = sDisplayClass;

this.statistics = sData;

this.typename = sTypeName;

this.category = iCategory;

this.ambiguousRecordsXml = sAmbiguousRecordsXml;

}

Encompass the code by means of reference or placement, and contact it within the fashion above and it’ll paintings.

Its up to you whether or not you wrap your determine name in a check (beneficial for shape load timing issues) but i found this worked in the long run.

So the SDK is adequate, but desires a piece of heritage know-how to work with. every other really helpful document that comes with the SDK is a pdf of the Microsoft Dynamics CRM four.zero UI fashion manual. vital to fit your UI to the relaxation of the CRM look and experience to make your IFRAME disappear – if you could paintings CSS and fashion of path!

Submit reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Login

Sign in to alux.com or create an account

Lost password?

Signup

If you already have an account, please sign in

Forgot Password

Please enter your username or e-mail address to recover your password.

Hey there!

In order to submit a post to Alux.com you must be logged in.

Already have an account? Click here to sign in