web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

The given key is not present in the dictionary

(0) ShareShare
ReportReport
Posted on by

Hi All

I am trying to add a new product to the Qoute but I am unable to add it and it's throwing me this error.

Please can anyone help me.

The Web Service plug-in failed in OrganizationId: 0e345f24-990c-e111-aeef-bc305be3b4de; SdkMessageProcessingStepId: 31154a44-8477-e311-bfd6-00155dcc2d07; EntityName: quotedetail; Stage: 40; MessageName: Create; AssemblyName: Plugins.CheckDiscountingbyLine, Plugins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=178b202c3a4f7a38; ClassName: Plugins.CheckDiscountingLevelByLine; Exception: Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

at System.Collections.Generic.Dictionary`2.get_Item(TKey key)

at Plugins.CheckDiscountingLevelByLine.Microsoft.Xrm.Sdk.IPlugin.Execute(IServiceProvider serviceProvider)

at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)

at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)

.

 

 

Thanks

Agni

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Deepesh161 Profile Picture
    6,317 on at

    Your plugin CheckDiscountingLevelByLine is missing some key which is not present in the attribute collection.

  • Suggested answer
    CRASH Profile Picture
    2 on at

    Hi Agni,

         You must be fecthing some existing Quote to add Products to, if you are using attributes of records fetched and its is null, this error will be shown, to get rid of this, use if(entity.Contains("Attribute name")){

    YOUR CODE

    }

    do this for all the Attributes you are using in code/ or / make sure all the fields you are using in code have values in them

  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Agni,

    The error is inside your plugin;

    V5PluginProxyStep.ExecuteInternal

    Try to check

    if(entity.Contains("xxx"))

    before you performing the action that involving the field object.

    Can be because that time it is NULL.

    Thanks

  • SonicVader Profile Picture
    on at

    brilliant as usual.

  • SonicVader Profile Picture
    on at

    I meant Aileen, briliant as usual...

  • Suggested answer
    Community Member Profile Picture
    on at

    Thank you! It worked.

  • Suggested answer
    muhammad.arshad Profile Picture
    45 on at

    This is a weird issue which is misleading and waste of time while debugging either using visual studio or through Plugin Registration tool profiling. Debugging gives exceptions at wrong lines and code.

    But I am 100% sure that most of the time this issue is related to any of attribute/field using in Query or Retrieve command is null and same field is being used anywhere in plugin code which is executable or reachable.

    Always try to use <entity_instance>.Attributes.Contains("<attribute_name>") before reading or writing it.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans