Thursday, July 28, 2011

Live Writer makes this easier

A friend just showed me Live Writer (from Microsoft) and it makes posting new blog entries much easier. For example, I can drop in a picture very easily

image

or format some code:

private int WorkflowID
  {
      get
      {
          int workflowID;

          if (ViewState["WorkflowID"] == null)

I can definitely see the value in this tool.

Tuesday, March 22, 2011

OpenXML and comparing versions

I am launching into using some OpenXML and found this nifty tool called the "OpenXML SDK 2.0 Productivity Tool for Microsoft Office" that is able to navigate the XML structure of the Office 20007+ document, and if you click on a node in the tree, it can show you the C# code that you would use to create that part of the document. It also has a nice XML file comparison tool built in that is smart enough to match up nodes of the XML tree regardless of the order they are in. It is part of the OpenXML SDK 2.0 download from http://www.microsoft.com/downloads.

Wednesday, January 12, 2011

MS CRM events and custom code

We are working on a large implementation of MS CRM for a client that requires a sizable amount of custom code in the forms. Here is one that tripped us up a "bit."

When working with bit fields (yes/no), you can change the way they appear on the form, as either a checkbox, pulldown, or radio button. We had some fields setup as radio button so that when the user changes one radio button, it would update other fields on the form. We wanted to make the code easier to work with so we took it out of the form and put it into its own custom javascript file that is included into the form when it loads.

For all the rest of our forms, the way we would get a script to execute is to use the attachEvent() method, so that in our .js file, we have:

crmForm.all.new_field.attachEvent('onchange', some_custom_js_function);

but we noticed that this didn't work on the radio buttons. After a bunch of searching, we found that it is really the onlick event of a radio button that we needed to attach the event listener to, so that we get:

crmForm.all.new_field.attachEvent('onclick', some_custom_js_function);

We later discovered that using onclick worked very well for the checkbox too - it had a very distressing behavior that it was not firing onchange until after it lost focus, but it does fire onclick as soon as the user clicks on it.

Let me know if you found this helpful!