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!

Thursday, October 21, 2010

Simple frustrations and workarounds

While working on an older install of CRM and writing some reports, I had to use VS 2005 for SSRS and it was a frustrating experience. For example, when working on a report design and trying to select a textbox, it seems like you need to click up to 3 times to make it select (sometimes more) so that you can just get the properties. I think this is because the first click will select the Table control row, the second click may select the textbox, or it will select the background cell. The third click will probably select the textbox.

So I have learned some alternative strategies to use the SSRS GUI:
1. When selecting an object, it is easier to use a fence rather than click on it. the Fence does not need to surround the object, just touch it so you can make very small gestures (click-drag) to select single items.
2. Sometimes even 5 clicks will not select the object because VSS is confused. Press the Esc key and try again – that usually works for me.
3. Use the document outline (on the left pane) to select objects – this is a good reason to name them. It also makes it clear what the correct container is for each object – very important to know when your report preview is not laying out the way you expect.
4. Do all my work within a single row of the table before working on other rows or headings because clicking outside the current row will force me to click two more times to get to the objects within that row
5. Use the fence to select many objects at one time, the use one of the many toolbar object alignment features that are actually very good (well worth spending 30-60 minutes playing to figure out how they will do your work for you).

Wednesday, October 6, 2010

MS CRM field events with bulk update

This is a good news /bad news story. I have a form that is heavily modified and has 1k lines of JavaScript (JS) code behind it. The good news is that it has a bunch of functionality that really makes the system sing - the bad news is that when you put code behind each field's OnChange event using form customization, then those fields are no longer usuable for bulk edit. This functionality is by design because CRM cannot execute your JS code for each record during a bulk update. In my situation however, I don't care; I still wanted both the customization and bulk edit.

My solution is to override the OnChange events without using the form customization UI. When my form loads, I import & execute a stand-alone JS file (in the forms OnLoad event) that contains functions that define OnChange events for fields. for example:

crmForm.all.new_investor.OnChange = function(){
alert("got here");
}

This code will execute when I change the investor field, but will not prevent the bulk edit from working.

Sunday, September 19, 2010

Quickbooks XML List ID relationships to Exported IIF refnum

I have a client that has been using exported customer lists in IIF format for a while in order to interface with an external system that creates invoices in IIF format.

As we are getting ready to move them into MS CRM with a QB link solution from Inogic, we discovered that the Inogic system uses the QuickBooks XML interface which exposes the internal ListID of the customer, and not the QB "refnum" used by their other system (via IIF file).

So the problem was that the old external system had a mass of data that used the QB Refnum field (from customer IIF file), but there was no way to correlate that with the XML version of the QB interface so that we could convert their data to the Inogic data. after a bit of playing with numbers, we discovered that the XML ListID's of the customers had a pattern and found that the first half of the ListID (before the hyphen) was really an encoded version of the Refnum.

To decode it, we used the following procedure:

1. Take the ListID and break it into 2 parts from either side of the hyphen and call them Part1 and Part2.
2. If Part1 is less than 7 characters, pad the left with zeros until it is 7 characters.
3. If the right 4 characters of Part1 ends with 0000, 0001,0002, or 0003 then get the first three characters from Part1 and convert them from Hex to decimal - that is the Refnum
4. If the first character in Part1 is "8", then use the last 3 characters from Part1 and convert them from Hex to Decimal and that is the Refnum.

Now that we have a Refnum for each customer that matches the ListID on the XML interface, we can convert all the data in the external system to use the correct customer linkage in CRM.

Sunday, August 29, 2010

MS CRM Autofilter gotcha

I am building a report using SSRS that I intend to use as an auto-filtered report inside of MS CRM (see http://blogs.msdn.com/b/crm/archive/2009/03/06/microsoft-dynamics-crm-pre-filtering-tips.aspx). The report pulls data from several views. Everything seemed to be working fine in development until I imported the report into CRM, then parts of the query seemed to stop working.

If you read the end of that article, it points out that all the entities referenced in the FROM or JOIN clauses will have a default filter applied to them that will limit what is included in the query to only records that were modified in the last 30 days.

In my case, I was using a parent entity with 4 outer joins, and I was only retrieving some of the data because some of the related tables had data that was not modified recently.

My solution to this problem was to create a single report that uses only one view with the CRMAF alias, and it used a sub-report that did not have the CRMAF alias on the views. This permitted me to associate the parent report with the entity, and pass the ID’s to the sub-report where there was no filtering.

In my case, I was creating a custom invoice for a custom invoice entity, so I created my parent report with just the one filtered view and gave it an alias of CRMAF_custominvoice. I embedded the sub-report in a table (tablix for VS 2008) control detail band, and gave the sub-report the ID value to pass as a parameter. In the sub-report, I had the rich and complex SQL that I wanted using filtered views, but not using the CRMAF alias.

Tuesday, August 10, 2010

Brokered Deposits - FDIC is wrong

I recently learned that the FDIC is working on implementing rules to limit (or prevent) brokered deposits at banks, ostensibly to prevent banks from being victimized by nefarious deals. Once again the government is doing its level best to show they are doing something even if it is wrong.

For those of you that do not know what a brokered deposit is, here is a link that explains it nicely:http://www.epfc.com/issuing_cd/faqs.html

In this case, our legislature has put too much power in the hands of the FDIC and they are going in the wrong direction. Rather than making the banks act responsibly and put rules into place that would hold individuals responsible for not doing their fiduciary due diligence, they are just about to regulate an entire sector of business (brokers) out of existence. Does this make sense?

If this rule is implemented, it will still be OK for you to buy a CD from a bank in bad financial condition, as long as you buy it directly. Think of it like buying a used car; are you in any better position if you buy it from an individual instead of using a dealer?

I would rather see the FDIC do their job and monitor banks that are in bad condition and make that information available to anyone. When a bank is in bad condition, cut them off so that they do not create a Ponsi-scheme-like situation. And if they do continue to transact bad deals, hold someone accountable and kick him out of the business or throw him in jail.

The more government regulation you create, the more people will rely on the goverment to keep them safe. People will have expectations that all investments are safe because the government said so. If the goverment keeps its nose out, then it would be up to the buyers and sellers to do their due diligence and act responsibly.

Take this story about traffic lights for example from John Stossel . The summary is that when you remove traffic lights, the drivers of cars expect that each intersection is a dangerous place and they will proceed through it more cautiously. As it turns out, accidents decrease to nearly zero and there are fewer traffic jams because cars rarely need to stop. Additionally, pollution in those areas have dropped significantly.

If you have a bank that has too many accidents, then take away their license and get them off the financial road.