Wednesday, July 25, 2012

Execute Server-Side Code from Javascript

Background:

General business rules shall be implemented in server-side code to ensure its execution regardless of the origin of data changes; CRM UI, workflow, integration or any other application consuming the CRM web services.

But on some occasions it would be handy to be able to execute this code from JavaScript to improve the user's experience of the application.

Scenario:

When creating or updating an Account, there is a plugin registered Pre Validation Create/Update to verify that the given VAT number is in a correct format. If not, the plugin throws an exception instructing the user to enter a correct VAT number.

VATincorrect

Another plugin is registered Pre Operation Create/Update to look up city/state/county from given zip-code to ensure correct data for the account. This function consumes an external service from a third party accessible as a web service.

Account Cinteros zip

Challenge

To improve user experience, the customer requires immediate verification of the VAT no and lookup of geographic information for the zip-code.

Wednesday, July 11, 2012

Adding Duplicates in N:N-Relations

The possibility to use many-to-many relations in Microsoft Dynamics CRM 2011 is very handy for various scenarios.
However, it's implementation is not very forgiving when you try to add a relation which already exists.
 
There is no way to configure the relationship or functionality of the "Add existing..." ribbon button to prevent this "ugly" message - so I decided to create a plugin which smooths things out, so that adding a relation which already exists only makes sure the relationship is there, but does not complain if it already was.
 
Scenario
We have a N:N-relation between Account and Product, to indicate which products are interesting to which accounts.
 
Clicking the Add Existing Product button brings up the lookup dialog for products.
When I now want to add a number of products, I do not want to have recall or check which products were already added. I just want to select all products (we can really sell anything to this company ;) click OK and be done with it.
 
Solution
We can create a plugin before main operation that verifies if the added relation already exists. But if it exists, we cannot prevent the relation from being created in any other way than throwing an exception, which will then result in a similar "ugly" message to the user, except it will contain the text we throw.

Wednesday, July 4, 2012

The Welcome Post

There must be a Welcome Post.
So this is it.

Welcome to my blog about development on the Microsoft Dynamics CRM platform!

The blog will focus on plugin development in C# and UI development in javascript, but in the words of mama Gump - Ya never know what'ya gonna get.