{Dynamics CRM Plugins + External assembly} Using external un-signed assemblies in plugin project

Have you ever faced this situation where your plugin or workflow assembly is referencing some utility assembly for which you do not have the code base. Well we had this situation very recently where we were required to refer to some external utility dll to perform some operations.

The problem we had is we did not have the code for the assembly. And for registering the plugin in Dynamics CRM, we need to sign the assembly. So when we were trying to build the assembly, we were getting ‘Referenced assembly does not contain strong name’.

The only way left was to sign the external assembly or load the external assembly dynamically in your plugin code. The second option was not possible since ours was online environment.

Finally after a good amount of search came across the below utility.

http://brutaldev.com/post/NET-Assembly-Strong-Name-Signer

And voila! I was able to sign the external assembly with my plugin strongname key. Attached is the screenshot of the tool.

image

Hope this helps.

Advertisements

{Dynamics CRM 2015 business rules }Why are my Business Rules not executing on the server side

Exploring the new features that came along with Dynamics CRM 2015 is fun indeed and what can be more fun than getting a chance to implement that in real time project. While going through the new features sometimes we tend to miss out on the small nuances that would actually make the new stuff to work as you like. And this is what exactly happened with my colleague.

So this is what he did. He had a workflow which when fired would create a contact. In the contact, he defined a business rule that would throw an error message if a particular business condition satisfied. For those who have not yet explored the new Business Rules feature of Dynamics CRM 2015 – With 2015 you can enable your business rules to fire from the server side also.

So my colleague was just joyous thinking about the fact that he no longer needed to write a plugin to do this stuff. Few clicks here and there and the job is done. However strangely enough even when the condition satisfied, there was no error and the workflow created the contact record.

So what went wrong here. Let’s see. For the blog since I could not present the actual situation of my client project, I would be just mocking up the scenario.

Let’s say we create a business rule which would throw an error message if the first name begins with D. No biasedness against people whose names start with D. Even mine starts with D Smile

Let’s see how the business rule looks like

image

 

Pretty simple. Isn’t it. Then I go ahead and activate it.

I have created a on-demand workflow which would create a contact with first name starting with D. Strangely enough when I run the workflow, the workflow is getting executed successfully and the contact is also getting created. So did my business rule not fire?

Time to get dirty. So let’s check our business rule again. When you create a business rule for an entity from form customization, the scope of it defaults to the default form for the entity.

image

To make the business rule fire on the server, you have to change it to the Entity. After I change it to entity and activate it and run the workflow again, I get the error and the contact is not created.

 

image

A small stuff but strangely enough many people forget while designing the business rules. Hence thought of sharing in case someone finds it useful.

Disable a composite control’s individual element in Dynamics CRM

Just the other day we had a requirement from the client where the in the contact form, if the user enters the zip code, state and the City would be populated automatically based on the zip code entered and the user should not be able to edit the state and the City fields.

Simple isn’t it. City schema name is address1_city and for state it is address1_stateorprovince. So my colleague was trying the following statements.

Xrm.Page.getControl(“address1_city”).setDisabled(true);

Xrm.Page.getControl(“address1_stateorprovince”).setDisabled(true);

And sadly enough it did not work. My colleague was getting an error.

The question is WHY? The reason is address1_city and address1_stateorprovince are individual elements of the composite control address1_composite. To fetch the individual control of the composite control, the format is <composite control name>_compositionLinkControl_<individual control name>. So to access the city control the code to do that would be as specified below.

Xrm.Page.getControl(“address1_composite_compositionLinkControl_address1_city”).setDisabled(true);

And you are done!

 

Please note: This would not work in tablet client since in tablet client, all the composite controls fields are rendered individually on the form. Hence to get access to the control you just have to specify. its schema name.

{Dynamics CRM web resource} Using HTML 5 session storage feature in Dynamics CRM web resources

Looking at the title of the topic, you must be wondering, is it something really related to Dynamics CRM. Well I would say a big Yes. Because it is an excellent HTML 5 feature and we develop HTML 5 webresources in our day-day activities. Being a dynamics crm consultant we sometimes  tend to miss out on some cool stuffs outside our CRM universe. For those who have missed out this one, I bet you would love it.

Many a times when we open a HTML webresource on the click of a ribbon button or some element click on the CRM entity form, we tend to pass parameters to the webresource. And sometimes we need to persist the value of the parameter in the webresource even if the webresource is refreshed.

Well you can use the cool HTML 5 feature of sessionStorage.

The sessionStorage persists as long as the browser window is open and gets deleted once you close the browser tab/ window. Another cool stuff about this is that it follows the standard key/ value model of storing the value just like any modern language.

Below is the sample code of how to set and get values from the sessionStorage.

 

image

It will persist your page refresh and unlike cookies it does not get posted to the server every time you submit your page.

Hope this helps!