Monday, January 25, 2010

Show field schema names in CRM 4.0 form editor

I recently worked on a project where the requirement was to rebuild an Excel-based quoting worksheet within a Microsoft Dynamics CRM 4.0 form.

Besides the code complexity (e.g., triggering the field onchange events appropriately), the other challenge was to keep track of the attribute schema name for 50+ form fields. (Note: The CRM form editor shows the attribute display name in each field rather than showing the attribute schema name. You can double-click a field to see its schema name but that’s too many clicks when you’re dealing with so many fields.)

What I really needed was a print-out of all of the form's tabs with the attribute schema name appearing in each of the fields. This would allow me to write the form’s Jscript code faster since I wouldn’t have to match field display names to schema names using the /sdk/list.aspx tool or other method.

One solution I came up with to show the field schema names within the form editor was to use the Script Editor that’s available in the IE WebDeveloper UI to change form’s HTML DOM on-the-fly.

Here’s how to do this:
  1. Login as an administrator in the CRM web application.
  2. Open the form editor for an entity.
  3. Press Ctrl-N to open the form editor in a window that gives you access to the IE WebDeveloper tool.
  4. In IE WebDeveloper, go to the Script Console and click Run Script.
  5. Copy/paste the code I’ve provided below and run it.
  6. Take a screenshot of the form.
Here’s a sample CRM form with the field attribute schema names showing.




Run this Jscript  code in the IE WebDeveloper tool’s Script Console window:
document.getElementsByClassName = function(cl) {
  var retnode = [];
  var myclass = new RegExp('\\b'+cl+'\\b');
  var elem = this.getElementsByTagName('*');
  for (var i = 0; i < elem.length; i++) {
    var classes = elem[i].className;
    if (myclass.test(classes)) retnode.push(elem[i]);
  }
  return retnode;
};
var crmFormFields = document.getElementsByClassName("field");
var crmReadOnlyFields = document.getElementsByClassName("rofield");
if (crmReadOnlyFields.length > 0) { crmFormFields = crmFormFields.concat(crmReadOnlyFields); }
var crmFieldId;
var crmFormField;
for (var i = 0; i < crmFormFields.length; i++) {
  crmFormField = crmFormFields[i];
  crmFieldId = crmFormField.parentNode.parentNode.parentNode.parentNode.id;
  crmFormField.innerText = crmFieldId;
}
Hopefully this will save you some time next time you’re working with a form and need quick access to the field schema names.
-Tim

Sunday, January 24, 2010

Microsoft's CRM forums... analyzed

I've been using a great full-text search application named dtSearch for several years but just recently discovered a feature that I'm finding more useful. The feature allows you to report on the count of words in an index. Combined with the ability to crawl entire websites, the two features can answer some interesting questions, such as the ones I came up with today: In Microsoft's CRM forums, what words are mentioned the most in the forum posts? In other words, what topics are people discussing the most in the CRM forums?

The answer to the question was easy to come by with dtSearch. First, I pointed the crawler at the three CRM forums and let it go until it downloaded all of the posts. I then exported a count of all of the words in the forums, removed the common "noise" words and came up with a pretty interesting list.

In the table below, I've listed the most occurring words in the CRM forums. I added some commentary to the first twenty words to give you an idea of what I've concluded from the word, but of course you can come to your own conclusions.

The Word# OccurrencesComments
entity24938An entity is what it all comes down to.
error16293Most of the use of "error" in forum posts relate to the generic "An error has occurred…". I'm guessing from this that a lot of forum posts originate from those who do not know how to turn on error-level tracing on the CRM Web server. Perhaps Microsoft could write full error details to a format that's easier to review, perhaps with a GUI they provide. Showing generic error messages and not providing customers with an easy way to get to the root of the problem leads to a lot of... forum Q&A's (and loss of productivity).
rights15287With the flexible role-level security features in Dynamics CRM, there are understandably lots of questions and problems relating to access rights.
workflow14382Plenty of questions about how to do something in workflow. A lot of the forum posts where "workflow" is mentioned also mentions "plugin", which tells me that people post questions about workflow and are told that they've hit a limitation and will need to write a plugin. Hopefully in 5.0 Microsoft will provide more workflow capabilities that don't require crossing over to code.
field14083Along with "entity", not surprising to see people needing to know how to update fields, make them read-only, etc.
custom13192It's not suprising to see this a top word considering that Dynamics CRM is highly customizable. This word is usually coupled with "entity", "attribute", or "field". But "custom application" is a popular subject as well.
account13037The top-mentioned entity type.
blogspot10848Looks like most people who mention their blog host their blog on blogspot.
contact10518The second most mentioned entity type.
donna10033This word occurs because Donna Edwards responds to a ton of questions. Thanks Donna!
problem9944Why else do people visit software-oriented online forums... because they have a problem... or an error. (It would be interesting to know the percentage of forum posts are answered to the originators satisfaction. I'm sure Microsoft has that stat.)
attribute8962The word shows up mostly in client-side SOAP XML that people paste into the forums.
davidjennaway8393David is a Dynamics CRM MVP who also answers a ton of questions. Thanks David!
outlook8393One of the significant benefits of Dynamics CRM is the ability to use CRM functionality seemlessly within Outlook. But the frequent occurrence of "outlook" in the forums means Microsoft needs to keep up the efforts to make the integration as reliable as possible.
update8277There are lots of ways to update data in CRM but there are lots of questions about how to do it.
check8234Most of the questions regarding the word "check" relate to the need to examine a field to then execute related functionality.
string7950The word "string" mostly appears in CRM Exceptions that people paste from their CRM trace files to the forum. By the way, the most common exceptions asked about on the forums are these (in order of word occurrence): SoapException, CrmException, InvalidPluginException, HttpUnhandledException, SqlException, WebException, TargetInvocationException, NullReferenceException.
find7637By far, the use of "find" in forum posts relate to "Advanced Find". It's a popular feature and people have lots of questions about its full capabilities.
view7276
lookup7193
sql7190
query7079
crmform6896
client6843
event6767
function6595
plugin6369
guid6138
imran6116
customereffective5967
sdk5938
activity5904
application5855
xml5806
button5543
javascript5531
please5474
context5341
crmservice5334
import5322
request5280
opportunity5228
execute5064
select5058
hassan4983
contacts4856
lead4779
possible4706
database4626
null4598
owner4526
click4480
default4431
soap4332
services4275
link4223
views4201
think4156
attributes4091
relationship4035
datavalue3955
reports3943
exception3806
properties3732
adi3648
works3648
msdn3628
example3605
option3593
tried3551
support3476
hope3422
address3390
product3384
andriy3383
picklist3352
isv3338
cannot3291
customer3284
settings3271
tostring3263
config3262
entityname3241
tool3231
security3223
iframe3211
leon3199
related3184
status3170
filter3161
xmlns3158
delete3120

And finally... my last name "Dutcher" appears 129 in the CRM forums. And I only found one swear word. The guy was having trouble with the flippin' Async service, but he didn't say flippin'.

-Tim