Saturday, February 27, 2010

Running a 32 bit command line app on a 64 bit platform

So I am currently working on a data migration into CRM 4.0 live. The various wrappers and libraries for the solution require that the executable run as a 32 bit application. To solve this problem do the following:

  • Start->Run
  • %windir%\SysWoW64\cmd.exe
This will open up a command prompt that utilizes the Windows-32-on-Windows-64 (WOW64) subsystem layer to run 32-bit programs.

There is an excellent post here with lots more details.

Music and passion...

Friday, February 26, 2010

Using Advanced Find to generate FetchXml

This post doesn't contain anything original. I stole this from here (good ones borrow, great ones steal). Here's how you use the Advanced Find functionality in CRM to create proper fecthXml.

  • Open advanced Find and press Ctrl-n. This will open Advanced Find in a separate window that gives you access to the browser bar
  • Define your query
  • Execute the query
  • Paste the following into the address/url bar in the browser:
    javascript:alert(resultRender.FetchXml.value); -- This will cause a javascript alert to pop up and display your fetchxml
Props to Ronald Lemmen for this excellent tip.

I just found another bit of of JavaScript that can assist you with this:

 javascript:void( new function(){ prompt("Fetch Parameters:",getFetchParams());function getFetchParams(){ return "FetchXml:\n" + advFind.FetchXml + "\n\n" + "LayoutXml:\n" + advFind.LayoutXml + "\n\n" + "EntityName:\n" + advFind.EntityName + "\n\n" + "DefaultAdvancedFindViewId:\n" + advFind.DefaultAdvancedFindViewId } } ) 

Thanks to Adi Katz for this great tip!

Happy coding!

Wednesday, February 24, 2010

View child objects in Iframe

This is a post for my benefit as I can't seem to remember anything. Here's the JavaScript code to display child objects of CRM object in an iframe.

  1. Create Iframe
  2. Modify onload event to populate iframe
  3. Make css changes to iframe to get rid of the white space around the iframe
Here's the code:

  var iframe = crmForm.all.IFRAME_AttorneyFees;
var url = "/UserDefined/areas.aspx?oId="+crmForm.ObjectId
iframe.src = url;

/*clean up css. Makes the iframe look lots better*/
iframe.onreadystatechange = function() {

if(iframe.readyState != 'complete' )
/*Change the background color*/ = "#eef0f6";
/*Remove the left border*/
iframe.contentWindow.document.body.all(0).style.borderLeftStyle = "none";
/*Remove padding*/
iframe.contentWindow.document.body.all(0).all(0).all(0).all(0).style.padding = "0px";
/*Make the cell the full width of the IFRAME*/
iframe.contentWindow.document.body.all(0).style.width = "102%"

The tabset variable in the url variable needs to be the name of the relationship to the child object. You can find this information in the relationships (left hand side of the customize entity form). You have to change the iframe variable to point to the iframe that you are pointing at. You can find this by using the customizations editor->iframe->Name.

Tuesday, February 23, 2010

Dynamic tabs in a CRM form

This post doesn't cover any new ground. This topic has been covered in other blog posts. But I'm tired of digging up these other sites as I can't remember anything. The goal of this post is to explain how to toggle the display of a tab on a CRM form. We need to accomplish the following:

  • Create function to toggle tag
  • Call function when the form is loaded
  • Call function when element is clicked on

Let's create the function (onload):

/*Create function to hide tab*/
crmForm.Neudesic_ToggleLawfirmTab = function() {

/*check the value of the checkbox*/
var value = crmForm.all.neu_lawfirm.DataValue;
if(!value) { = "none";
} else { = "block";

Now let's take care of the last two issues:

if(crmForm.FormType == 1 || crmForm.FormType == 2) {
/*make sure the proper tabs are displayed*/

/*attach custom function to new_lawfirm element.
The CRM onchange event doesn't fire until the checkbox element
losses focus. I don't like this. So let's attach the event*/
var element =
element.attachEvent("onclick", crmForm.Neudesic_ToggleLawfirmTab);

There you go! A couple discussion points. I don't like using the onchange event handler that CRM exposes for checkboxes as it doesn't fire until the element looses focus. So I use attachEvent to get the function to fire. Note that you can also use element.onclick. However this will override any other JavaScript functions that are attached to the element in question. Not really the best approach; especially when working with other developers. Also note that the toggle function is a child of the crmForm object. This allows for the function to be called in a onchange event from another CRM form onchange/onsave event. Defining as a free standing function will cause scope to be lost in another onchange/onsave event.

Keep in mind that in CRM 5.0 form tabs are going away. So this code will not work; but that doesn't matter now does it? Your technical; act like it. Solve the problem when it appears and know that it's coming. In the meanwhile you customers/users now have one more reason to love you...

Happy coding!

First post!

I'm done digging through piles of code to find some obscure solution that, at one point in time, I was very proud of but have now forgotten. The primary focus of this blog will be around technical solutions for Microsoft CRM. However, I reserve the right to ramble into the open source world from time to time and to shamelessly promote my band, Black Mercies; as well as make money from your visits to this site.

I hope you find this useful and entertaining...

Ones and Zeros,

Concrete and collapse

Your high priest to the Gods of technology... Sacrifices are accepted.