Friday, 20 May 2016

CRM 2016 - Synchronous Workflow bug

Today I spent quite some time working on a bug in one of our workflows which ended up being a bug within CRM. The error I was getting was
The given key was not present in the dictionary.
Let me show you how to recreate and how to spot that this is infact an issue within CRM as opposed to your code.

In our CRM we have a concept of an Attendee which is how we link people to a meeting. We also have the concept of a Target entity which is a parent of an Attendee. The lookup to Target on Attendee is not mandatory as some attendees are just regular people (i.e. not linked to a "Target"). When an Attendee is linked to a meeting I want to check a target has been set and and if it is do some "stuff" based on Target information. So I create a workflow with just this check in it:



For now I am not going to add anything else as this is all I need to highlight the bug. Next, as with a lot of systems, we have bad data and not all Targets have a name. For example:



I run my workflow in its current state against this record and I get an error

:

Downloading the log file gives you a trace like this:

[Microsoft.Crm.ObjectModel: Microsoft.Crm.Extensibility.InternalOperationPlugin]
[46f6cf4c-14ae-4f1e-98a1-eae99a37e95c: ExecuteWorkflowWithInputArguments]
Starting sync workflow 'CG - workflow with bug', Id: e717769d-8c1e-e611-80f4-5065f38aa981
Entering ConditionStep1_step: Check Attendee.Target contains data
Sync workflow 'CG - workflow with bug' terminated with error 'The given key was not present in the dictionary.'

I'm not sure what the CRM workflows code is doing under the hood here, but it must be trying to reference the name field in code. If you set a value for Name on the Target the problem goes away.
Pro tip: Put comments in your workflows! They are included as part of the trace



3 comments:

  1. Replies
    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance




    Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance



    Hello All ▲▲▲ I am Dianna Kent and I live in Nevada, U.S .I am a full member of the Illuminati brotherhood, and am among the 1252 lodge. ▲▲▲ Iwas ordained by the Grand-master to go out to the world and bringmore members to the Illuminati, ▲ so I was requested to get 400Recruits for the brotherhood, I have 210 new recruits already. I amlooking for only 190 more to go,▲I am sure you want to be amongthe 190 people that will be earning $500,000 monthly and a brandnew car, ▲so add me up now so we can achieve this great chanceof being rich ▲. You get to live your dream life on earth filled with luxury. so i urge you not to miss thisGreat opportunity becoming what you long wished for life email: illuminatitemple6634@gmail.com‬ or Whats-app +1(854) 220-5771 for guidance

    ReplyDelete