Microsoft Dynamics CRM

{Make some Noise} Dynamics CRM 2016 is here!

Hi All,

Dynamics CRM 2016 is available now: https://community.dynamics.com/b/msftdynamicsblog/archive/2015/11/30/microsoft-dynamics-crm-2016-now-available-ushering-in-a-new-era-of-intelligent-customer-engagement

Hope it helps and Happy CRMing!

Advertisements
Microsoft Dynamics CRM

Useful resources for up to date news on Dynamics CRM from my end

I just wanted to highlight the fact that CRM is making changes at a very fast pace and there would be lot of useful information coming your way, just like it does to me.

So I had a query recently on what are the best ways you can keep up to date via my blog?

Not many people who follow my blog via email might have noticed that I have a twitter handle as well.

clip_image002

My twitter handle is @msdynamicsblog

This is surely the best way to get my instant tech tweets and retweets.

clip_image004

Then if you are not really into following any kind of instantaneous tweets you can always follow my blog via email.

What is the way of doing it?

On the right hand side of my blog there is a small area to follow my blog via email. Every time I post something new you will have an email.

clip_image005

There are some groups as well:

clip_image007

Then there is yet another way, you can go to the LinkedIn Group named Dynamics CRM 2013/2015/2016 Consultants here.

This is more focused on versions 2013 and up and there is loads of information to consume from here.

I myself administer this group for now but am looking to have more admins, so if you like a bit

of administration work let me know in comments.

clip_image009

Another effective way is to drop me an email if you need information on anything specific and think I can help. Here is my email: deepeshsomani@hotmail.com . Sometimes, might take few days but I do respond on it.

clip_image011

I also have a query/feedback form on Dynamics CRM blogs here

Hope it helps and Happy CRMing!

Microsoft Dynamics CRM

{ADVANCED CODE TIP}My take on the Key not found exception in Dynamics CRM Plugins

Many times we have been there that we get the exception from our plugins called “The Given key was not found”.

The problem with Dictionary collection is that it doesn’t give the key name when it is not found.

The reasoning which I read on different blog posts, forums and Microsoft is key, value pair can be any type.

So, key name is not given in the exception.

clip_image001

But I wanted to have the key name in the plugin log.

I spent many weeks with this exception in my CRM online project and trying to understand how this can be custom built.

So, I have implemented this change on the plugins:

     string[] Cols = { “name “,“accounttype “};

     Object outValue;

            var fieldsMisssing = string.Empty;

            //Do tracing for key not found exception

            foreach(string str in Cols)

            {

                if(!entity.Attributes.TryGetValue(str, out outValue))

                {

                    fieldsMisssing += str + “,”;

                }

            }

 

            fieldsMisssing = fieldsMisssing.TrimEnd(‘,’);

 

            if (fieldsMisssing != string.Empty)

            {

                tracingService.Trace(“Following keys were not found: “ + fieldsMisssing);

            }

 

The result is I have a log in my Plugin trace whenever there are missing keys (Under Settings-> Plug-in Trace logs):

clip_image001[8]

Hope it helps and Happy CRMing!

Microsoft Dynamics CRM

{Advanced Code Tip}Creating Atomicity of a Transaction in Dynamics CRM 2015

Consider how many times you have been around in the scenario that you are doing some integration or

a batch job with Dynamics CRM and in the interim there is an exception, so you need to design rollback for your job/integrations.

With Dynamics CRM 2015, designs can be simplified way further. There was a new request type introduced with Dynamics CRM 2015: ExecuteTransactionRequest.

In the example below I have intentionally left an error and I am trying to either create a contact and account together or none.

Exception scenario:

using (var service = new OrganizationService(connection))

            {

                ExecuteTransactionRequest request = new ExecuteTransactionRequest();

                Entity account = new Entity(“account”);

                account.Attributes[“name”] = “Transaction Test”;    

                Entity contact = new Entity(“contact”);

                contact.Attributes[“name”] = “Transaction Test Contact”;         

                CreateRequest create1 = new CreateRequest();

                create1.Target = account;

                CreateRequest create2 = new CreateRequest();

                create2.Target = contact;

                request.Requests = new OrganizationRequestCollection { create1, create2 };

                ExecuteTransactionResponse response =  (ExecuteTransactionResponse)service.Execute(request);

            }

Exception:

clip_image002

In this case, Even account was not created:

clip_image004

After Correction:

   using (var service = new OrganizationService(connection))

            {

                ExecuteTransactionRequest request = new ExecuteTransactionRequest();

                Entity account = new Entity(“account”);

                account.Attributes[“name”] = “Transaction Test”;    

                Entity contact = new Entity(“contact”);

                contact.Attributes[“lastname”] = “Transaction Test Contact”;         

                CreateRequest create1 = new CreateRequest();

                create1.Target = account;

                CreateRequest create2 = new CreateRequest();

                create2.Target = contact;

                request.Requests = new OrganizationRequestCollection { create1, create2 };

                ExecuteTransactionResponse response =  (ExecuteTransactionResponse)service.Execute(request);

            }

Created two of them together:

clip_image002[6]

clip_image004[5]

Hope it helps and Happy CRMing!

Microsoft Dynamics CRM

{Quick Reference} Top Posts from the Last Quarter

Here is a quick look into my top posts from the last quarter:

Refresh CRM 2013 Form using script

   

{Useful to know}CRM Forms loading too slow: Check OUT this USEFUL list

   

Get/Set currency field values in JavaScript for Dynamics CRM

   

Change Business Process Flow using JavaScript

   

Change color for text fields : Dynamics CRM 2013

   

ERD Generator for Dynamics CRM 2011/2013

   

{New utility}Activity Timeline for Dynamics CRM 2015

   

{Quick Tip}Server side sync vs Email router in CRM 2013/2015: What to choose?

   

Cleared MB2-704 MICROSOFT DYNAMICS CRM APPLICATION CRM 2015 Exam

   

CRM 2013 Create Email error – Cannot open Sql Encryption Symmetric Key because Symmetric Key password does not exist in Config DB.

   

Hope this quick reference helps and Happy CRMing!