Wednesday, December 22, 2010

Show attribute schema names within form editor

Maybe it's just me, but occasionally I find value in viewing attribute schema names in context of a form. This capability was on my wish list for Dynamics CRM 2011 but it didn't make the cut. Fortunately, you can run the JavaScript code I provided below to do just that.

You can execute this script and any other JavaScript code using the built-in "Developer Tools" in IE8 or by using IE WebDeveloper. First, load the form editor view (CRM displays the form editor UI in its own window). Then press Ctrl+N to open the editor in a window that allows you to get to the IE toolbar. Either press F12 (IE 8 only) or use IE WebDeveloper. Run the script in the interactive script window that's provided in each tool.
document.getElementsByClassName = function(cl,doc) {

  var retnode = [];
  var myclass = new RegExp('\\b'+cl+'\\b');
  var elem = doc.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 doc = document.getElementById("contentIFrame").contentWindow.document;
var crmFormFields = document.getElementsByClassName("field",doc);
var crmReadOnlyFields = document.getElementsByClassName("rofield",doc);
if (crmReadOnlyFields.length > 0) {
  crmFormFields = crmFormFields.concat(crmReadOnlyFields);
}
var crmFieldId;
var crmFormField;
for (var i = 0; i < crmFormFields.length; i++) {
  crmFormField = crmFormFields[i];
  if (crmFormField.parentNode.parentNode.parentNode.parentNode.name) {
    crmFieldId = crmFormField.parentNode.parentNode.parentNode.parentNode.name;
    crmFormField.innerText = crmFieldId;
    crmFormField.style.color = "#000000";
  }
}
Here's a snapshot of part of the Account form. After running the script, the display name for each attribute is replaced with the schema name.

 

Thursday, October 14, 2010

Party Foul

Oh no! What's this?!?  Failure: contact_activity_parties: Cascade link type 'NoCascade' is invalid for Delete.


I ran into that error today but found a way around it. Here's the scoop.

I fired up a VPC with Dynamics CRM 4.0 Rollup 13 today and added 21 attributes to the Contact entity, which was previously unmodified. I then exported the Contact entity to XML and send the resulting zip file to someone I work with. He has the main VPC and needed some help. Anyway, he attempted to import the Contact entity into another CRM Rollup 13 instance and got the error I mentioned above.

After calling each other crazy and demanding proof that we were both running Rollup 13 (we were... not crazy, but running rollup 13, well maybe both), I exported the Contact entity and immediately re-imported the zip file. Bam! Same error... on the same CRM instance! Grrrrr.

The "solution"?  I removed the node "<EntityRelationship Name="contact_activity_parties">" from the Contact XML, saved the file, and wouldn't you know it, CRM imported that version of the customizations file just fine.

I'm sure, I have to believe, okay I hope (but not holding my breath) that Microsoft has made customization import/export rock solid between rollups in Dynamics CRM 2011. I can understand that moving customizations between different rollups is hard for Microsoft to get right but exporting and re-importing on the same server, within only 38 seconds lapsing between the time the zip file plopped onto C: to when I optimistically clicked the Import button -- for that not to work is, well, causing me to write this blog post instead of working. So with that, onward to the next challenge.

Friday, September 10, 2010

Dynamics CRM 2011 Beta SDK Greatest Hits

Here are some articles, notes, and tidbits I've found so far in the Dynamics CRM 2011 SDK that are particularly cool, as compared to the now "old school" version 4.0 of the product.
  • Azure Integration: In simple terms, the CRM async service can send messages to a queue in Azure to process. That will make this 4.0 application better because I can now perform integration tasks from CRM changes rather than using a polling service.
  • Multiple Forms for an Entity: You can define more than one main form for each entity. Use multiple forms to create forms that are customized to specific roles or tasks in the organization.
  • REST Endpoint: In 4.0, writing client-side code in SOAP is not exactly fun or easy. In 2011, you can replace a lot of that code with REST-based calls using JQuery or other jscript libraries.
  • Goals!: Goal Management enables you to set the sales, marketing or other business goals for your organization and measure the results against the targets.
  • Silverlight Samples: It's great to see sample code in the SDK for interacting with Silverlight applications. Of course, David Yack was way ahead on this but this adds to the cool factor in the SDK.
  • Data Auditing: Audigint is built in and can be enabled at the organization, entity, and attribute levels.
  • Custom Activity Types: You can create your own activity types to track customer interactions that go beyond the built-in phone, letter, e-mail, task, etc. For example, if you business has a customer portal for service incidents, you might want to track interactions in the portal as a custom activity type.
  • Web Resources: Web Resources are 'virtual files' that are stored in the CRM database and may be retrieved using a unique URL address. Web Resources can be used in Form customizations, Sitemap or the application ribbon.
  • Sandbox for plug-ins: CRM Online will benefit from the ability to run plug-ins in an isolated environment. In this environment, also known as a sandbox, a plug-in can make use of the full power of the CRM SDK to access the Web services.
  • Entity Connections: A person I worked with at a large Northwest company has a brother who I run into often while hiking in the Cascades. He works for a subsidiary of the larger company. Now, in CRM 2011, I can connect those contacts in ways that helps me and others at Altriva know how they're related (or conneted) to each other.
  • PowerShell Cmdlets: The Beta SDK has placeholders in the documentation for instructions on how to use PowerShell to help with deployment-related tasks.
  • Solutions: Solutions are how customizers and developers author, package and maintain a single unit of software that extends Microsoft Dynamics CRM.
  • Recurring Appointments: Create recurring appointments with flexible intervals/patterns.
One feature that I'm hoping Microsoft will hurry and add is one that can generated a unique number. This is a common customization that we add for our clients but it really should be built in to the product.

Monday, August 23, 2010

Azure / CRM app won't deploy - Initializing, Busy, Stopping

I made a simple code change to an Azure WorkerRole service today. Before deploying the app, I noticed that the folder where my code lived on my machine didn't match up with source control so I did a little readjusting of folders. No big deal, I thought. The application compiled fine and ran on my local dev fabric.

After deploying the updated Azure service, the deployment screen showed Initializing, then Busy, followed by Stopping... and then went back to Initializing, Busy, etc. It was stuck in a loop. I read something about this in the past and knew that it related to invalid DLL references, invalid configuration or a number of other things.

After convincing myself that my code change was working and  had proper exception handling just in case, I put all the pieces of the application back in their previously known working locations. Voila! The application deployed to Azure fine.

What happened is that Visual Studio started referencing 32-bit versions of the CRM SDK assemblies (microsoft.crm.sdk.dll and microsoft.crm.sdktypeproxy.dll) when I moved the application to different folders -- it could no longer find the 64-bit files I referenced previously. So when I deployed the application the 32-bit CRM assemblies went along up to Azure... but Azure only runs with 64-bit assemblies!

I was punished once again by good intentions. But at least I can add this troubleshooting lesson to my list for future reference.

Wednesday, August 18, 2010

Notification of activity changes in Dynamics CRM 4.0

There's a Windows desktop app that I've been using named "Check&Get" that notifies me when someone modifies content on any of about 100 websites that I follow. Once each day, I go to Check&Get and can see what websites have significant content changes. This is especially helpful to keep up on blogs.

Today, I found another use for Check&Get. I work at Altriva Solutions and last year I helped create an "ISV" application for CRM 4.0 (on-premise and online) named "CRM Activity Summary". This application brings together all activities, notes, attachments, e-mails, etc. for any account, contact, opportunity, case, etc. and displays that content on one page. For example, if I'm looking at the account form for one of our clients I can see all activities, e-mails, notes, etc. for that account and all connected contacts, opportunities, and cases -- all on one page!

Since Check&Get can monitor any web page, and Altriva CRM Activity Summary can construct a web page of all rolled-up activities for an account record in CRM, my thought was that perhaps I could point Check&Get at the CRM Activity Summary page for the accounts I work with and let it tell me when anything has changed. It worked! I now have complete and timely visibility into several clients' activities and will know within minutes when anything has changed and can act (or not) as appropriate.

Let me know if you'd like more information about the Altriva CRM Activity Summary application or the Check&Get and Activity Summary "mash-up". It actually took me longer to write this blog post than it did to get that mash-up working... so if you need a quick and easy way to keep on top of CRM changes then this is one more way to do it.

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