Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Dynamics CRM PLugin Error

Posted on by 605

Hi all,

I am writing a plugin on account entity, i.e. when account record is created a new contact record must also be created subsequently. My code is as shown below:

try
{
Entity entity = (Entity)context.InputParameters["Target"];
Guid accID = (Guid)context.OutputParameters["id"]; // error is in this line "The given key is not present in the dictionary"

Entity contact = new Entity("contact");
contact["lastname"] = "Test";
contact["parentcustomerid"] = new EntityReference(entity.LogicalName, accID);
service.Create(contact);
}
catch (Exception e)
{
throw new InvalidPluginExecutionException(e.Message);
}

It is throwing me an error saying "The given key is not present in the dictionary".

I am not sure as to what is the problem. 

*This post is locked for comments

  • Rahul G J Profile Picture
    Rahul G J 605 on at
    RE: Dynamics CRM PLugin Error

    Perfect! got it.... i was doing pre-operation which was wrong.

    Thanks Andrii... for the help.

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Dynamics CRM PLugin Error

    Hello,

    You should use Post-Create in plugin step registration window. Can you please provide a screenshot how you registered your plugin?

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