Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Workflow error - Given key was not present in the dictionary.

Posted on by 485

Hi there,

I have seen this issue since CRM 2013, but I am just very surprised that it hasn't been fixed by Microsoft. 

Basically, if we have a Check Condition in workflow to check whether a lookup record exist or not, it will fail with error 'Given key was not present in the dictionary' if the lookup record exists without primary name (or blank). This issue occurs on any system and custom entities.

To replicate this issue:

1. Create the workflow:

a. For any entity, I use Email in my example. Use synchronous for immediate result, same error will occur in sync/async.

b. Add Check Condition, where Regarding (Case)->Case contains data.

c. Create a new Task, populating the Task->Subject with Case->Case Title. Publish the workflow.

2. Go to customisation, and make the Case Title optional.

3. Create the test record, ie. new Case without Case Title. Then, create a new draft Email regarding the Case above.

4.  Then, run the workflow created above on the Email. The workflow will fail. However, if you populate the Case Title with some text, then run the same workflow. The workflow will successfully create the Task record.

In real business scenario, this error is problematic when we have Case Creation Rule creating new Case from emails, and the inbound Email does not have a subject. Hence, the Case is created without Title, then the workflow failed.

Although, I could create new synchronous workflow to populate the Case Title on create if blank. However, I do not feel this is a proper solution as the workflow error will occur in any entities, and I am surely not feeling comfortable for creating such workflow in all entities.

I have reported this issue with Microsoft Support and was handled by Wipro - Support ref REG:116102094910228. The best solution they came up is ask the user to populate the Case Title, and not willing to escalate this issue to a more senior support team (or CRM development team for further investigation).

Would you agree that this is a bug in CRM workflow platform or is creating a workflow to populate the proper solution?

Regards,

Henri

*This post is locked for comments

  • HenriL Profile Picture
    HenriL 485 on at
    RE: Workflow error - Given key was not present in the dictionary.

    Thanks Abed.

    That may resolve the problem in this specific scenario because the Case Number is a system required field, if I am not mistaken. However, what about a custom entity as there is no system required field enforced by the platform.

    I guess the above solution is not addressing the inherent problem that a check condition in a workflow should not ever cause run-time error but return only either true or false, unless it is calling a custom workflow assembly.

    Thanks.

  • NatrajY Profile Picture
    NatrajY 3,040 on at
    RE: Workflow error - Given key was not present in the dictionary.

    Connect is still used for the "Microsoft Dynamics Preview & Feedback" program. If you are part of the preview program you should be able to access the link after signing in.

  • HenriL Profile Picture
    HenriL 485 on at
    RE: Workflow error - Given key was not present in the dictionary.

    Thanks Natraj. I am glad that there are others whom have the same opinion. Just tried to access Connect, but could not find product named 'Dynamics CRM' or 'CRM'. Perhaps, they are in progress of renaming the product to 365.

    The site hasn't changed since I accessed it 3-4 years ago. Looks abandoned.

  • Suggested answer
    Abed Haniyah Profile Picture
    Abed Haniyah 4,285 on at
    RE: Workflow error - Given key was not present in the dictionary.

    Try to change the condition like this :

    If Regarding(Case)Case Number contain data then

    I met the same issue on a real time workflow on queue item and I changed the condition from Object (Email)Email to Object (Email) Sender Email and it was working fine :)

    0116.Capture.PNG

  • NatrajY Profile Picture
    NatrajY 3,040 on at
    RE: Workflow error - Given key was not present in the dictionary.

    It is a bug but MS won't fix it. Refer connect.microsoft.com/.../realtime-workflow-action-crash-display-name-if-condition-keynotfoundexception

  • HenriL Profile Picture
    HenriL 485 on at
    RE: Workflow error - Given key was not present in the dictionary.

    Thanks Prashant.

    The workflow simply checks if the Regarding contains a Case record or not. Technically, it should return true because the Regarding has a value regardless of the primary field containing value or not.

    Should the following step pointed by the blue arrow cause a run-time error at all? Currently, it does if the Case doesn't have a value in the Case Title.

    7587.Capture.PNG

    If a primary field must be populated then shouldn't this validation be enforced at the platform level, as currently the primary field of any entity may be changed to Optional.

    Also, if you read my previous point is that Case was created via Case Creation Rule. Therefore, using just out of the box features, a workflow created without custom code will produce a run-time error.

  • Suggested answer
    PS Profile Picture
    PS 23,577 on at
    RE: Workflow error - Given key was not present in the dictionary.

    I would not say its a bug. its the design of the system.

    Case Title is a Primary Field and its required to populate a case in any lookup. When the workflow searches for a regarding value. it could not find it and thats why this error.

    Solution provided to you by Wipro seems appropriate.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans