Pages

Thursday, February 6, 2014

I’m not dead yet!

It’s about time that I come to you, the Dynamics CRM Community, you rich and vibrant thing, with an apology and an explanation for my relative absence over these bitter winter months.  Rest assured that I’m not dead.  (And if that assures your unrest, then I can’t help you.)

It has been ages, it seems, since I answered a forum post, and longer still since I published a blog post of technical merit.  As such, I felt that I should at least fill what scarce readers I may still have (those devoted, loyal few) with some hope and information about what I’m working on for them.

Firstly, and most looming, I will be at Convergence 2014 in Atlanta.  Not simply as an attendee, mind you, but as a co-presenter with the indomitable George Doubinski.  Together, we’ll present “heroic” development topics under the CRMUG banner, and hope to see many of you there!

Secondly, an unnamed book project should also be published this year, with my name found upon it.  The details of this are intentionally vague at this point, as I’m still uncertain what more I can say about this work.  However, I am honored to be involved, and hope I can deliver compelling and useful content for other Dynamics CRM developers.

Lastly, I’ve been working tirelessly for my employer, Avtex, and have taken extra effort to identify and isolate many functional components that we can release as free community offerings.  Obviously the intent is to stoke the fires of interest around Avtex in the Dynamics CRM space, but also to introduce the community to our “Avtex 360” concept: that to provide a better experience for our clients’ modern customers, we apply experienced and tech-savvy consultants and implementers across all points of interaction, and optimize those points with robust and tight integration between platforms and processes.  Dynamics CRM is but one pillar of that mission, yet with strong engagement and recognition in several industry venues (and a varied and recognizable client portfolio), Avtex is not only a clear leader, but possibly the best kept secret in the field of Customer Experience (CX).

So, that’s where I’ve been and what I’ve been up to.  However, as a Microsoft MVP, I’m continually looking for ways to squeeze in events and community face-time, so I’d like to also mention some up-coming events in which I’ll be participating in the coming weeks:

I’m also trying to back-fill some content that supplements a webinar I gave last year on xRMVC, which I did for CRM Partner Connections (CRMPC), an offshoot of CRMUG.  That probably won’t see the light of day until April or May, but we’ll see. 

So, in closing, I’m not dead yet, and I hope to see you soon!

Thursday, September 5, 2013

The CRM Field Guide… Guide

You might not know it, because I’ve been silent on the matter, but I am a contributing author to The CRM Field Guide.  Specifically, I authored Chapter 24: Rapid Development Best Practices.  The intent of the chapter is to introduce people with backgrounds similar to mine to the practices I have developed over the years to produce code for CRM 2011, well, rapidly.  However, before I delve into some of the meat and value of the book or my chapter, I’d like to journal my experience of writing for the book.

It’s been stated before that the project was long-running, with several starts and stops along the way.  To the credit of Donna Edwards, Julie Yack, and Joy Garscadden, wrangling so many MVP authors was not a minor task.  As MVPs, we are all actively engaged in the Dynamics CRM community, while working day jobs.  These responsibilities conjointly leave precious little time for most other endeavors, family notwithstanding.

I was brought into the project later, and given the opportunity to write about my passion: development.  Because my exposure to CRM 2011 was light at the time, from a technical standpoint, and because many other authors covered a great deal of the technical components (solutions, customization strategies, etc.), I decided to focus on the tools and processes I use to handle development projects from start to end—evolved from my experience with CRM 4.

Deadlines were short, and yet I somehow ended up producing the single largest chapter, as measured in raw word counts.  It was amazing to write professionally, and the passion carried me quickly through my task.  To be a published author, for the first time, had been a dream as strong as my passion to become a professional software developer.  Marrying both experiences together is my crowning achievement.

However, I remain dissatisfied with my content—deserved or not.  It has received high praises from reviewers and developers who are introducing themselves to Dynamics CRM, yet I feel as though it could be better.  Perhaps, sometime soon, I’ll produce something stronger and (in my eyes) worthy of my audience.  Apart from this private embarrassment, I have been biding my time in writing up anything because many other authors have continued to do it on my behalf.  (Thanks!)

So why break the silence?  Because Jerry Weinstock, of “Jerry Weinstock” fame, has produced a Training Curriculum addendum, for the following roles:

  • CRM Admin
  • Power User
  • Business Analyst
  • IT Support
  • Developer
  • New User

He has expertly fleshed out approximately 10 to 15 chapters from the book that serve as reference material for each role, and stands as a fantastic appendix to a fantastically dense and useful book!  This curriculum is affectionately referred to (by me) as The CRM Field Guide Guide, and will help each role focus on their specific area of expertise or interest.

Jerry’s efforts will hopefully illustrate that the versatility of the book’s expansive content suites many purposes, and articulates its value in the library of any organization that works with Dynamics CRM.  Thank you, Jerry, for adding value to an immensely valuable resource.

Where can you obtain it?  Well, because the curriculum is only useful in the context of the book, it’s available as downloadable content (DLC) for all who purchase The CRM Field Guide, either in hard or digital copies.  To celebrate this addition, I will provide a discount code for the digital copy of the book to the first 10 people who tweet a mention of the book (crmfieldguide.com), and include me (@crmentropy) on it.  Look out for a Private Message from me!

Cheers!

Wednesday, August 28, 2013

Entity.GetAttributeValue<T> Explained

The CRM 2011 SDK offers a handful of useful extensions over the previous versions that many Dynamics CRM developers have come to appreciate.  One in particular that I’ve only recently come to use is the Entity.GetAttributeValue<T> method.  I’ve seen it used in many places, and have started using it myself, but I never really fully understood how it can be expected to behave.  The Microsoft documentation—as with a great deal of the SDK—doesn’t offer much on this particular method, and no example code.

I’ve found myself continuing to lean on Entity.Contains as a measure of safety, and checking the Entity indexer for type (using the “is” keyword), to make sure I wouldn’t violate a Type constraint.  My concerns have been alleviated today when I took a few minutes to run some scenarios through the method, to see what the results were.  There’s some good news I’d like to share.

The given key was not present

The only method parameter taken by Entity.GetAttributeValue<T> is the name of an attribute.  If that attribute is not present in the Entity instance, it will not generate an error.  Instead, the method will return a “default value” of Type T, or null if T is nullable.

Be careful of assuming this means that the Entity contains your attribute, however, because it may not.  Entity.Contains will assure that a null return from Entity.GetAttributeValue<T> means that the attribute is truly null, and not just effectively null because it is missing.

Nullable Types

The non-primitive types provided by the SDK are all nullable (e.g. OptionSetValue, Money), meaning returns of these types will be a complete instance of the Type, or null.  However, the primitive types the SDK uses are not inherently nullable (e.g. int, bool).

What happens if you pass a non-nullable type into the Type parameter T, and the value for requested attribute is, in fact, null?  Well, thankfully the SDK converts the null into a bitwise 0 value for T.  This is what I call the “default value”, and I’ll get to that in a moment.

If you prefer to always receive null, instead of the “default value”, then you can pass a nullable-extended, primitive Type (e.g. int?, bool?, decimal?), and the SDK will cast the requested attribute accordingly.

Default values

A “default value” is the result of a null return being coerced into a non-nullable type.  The null return could be either: a) a missing attribute, or b.) a null value on the attribute.  When converting null, the SDK selects a bitwise 0 value for your type.  Consult the chart below for the expected returns:

Type

Return
Numerical (int, decimal, double) 0
Boolean false
DateTime DateTime.MinValue
Guid Guid.Empty

This can be handy, if you are performing calculations on primitive types, and would rather not write several lines of code to weed out null values (since performing any mathematical operation on null results in null).

Specified cast is not valid

If, by some misfortune, you pass a Type to the T parameter that is not Metadata-compatible with the actual value of the attribute you requested, this method will thankfully throw an InvalidCastException, rather than returning a default value.  This assures you that you’re not mismatching Types.

For example, if an attribute is int and has an int value, but I pass ‘decimal’ to T, my code will throw an InvalidCastException.  Even though casting an int to a decimal is trivial for .Net, if my supplied Type does not match the Metadata schema, I will run into this exception.

Conclusion

So there you have it, a full rundown of how Entity.GetAttributeValue<T> works and how you can expect it to behave in your code.  Hopefully, you’ll realize like I did, that you can save yourself a lot of code by using this method and relying on its undocumented behaviors.  It was a fantastic add by the Dynamics CRM development team, and a hidden treasure for developers like me who became accustomed to writing all manner of attribute evaluations with previous versions of the product!