Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7719091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:19:37+00:00 2026-06-01T03:19:37+00:00

I am new to CRM development. I have a Custom Entity customer. This Entity

  • 0

I am new to CRM development.
I have a Custom Entity “customer”. This Entity has a Field called “defaultcustomer”, which can be TRUE or FALSE. I am working on a Plug-In where i need to set the “defaultcustomer” to FALSE for all the “Customers”. I am doing it as below:

FACTS:

I have registered the plugin for the entity “customer” itself. So when the Entity “customer” is updated, the plugin fires.

private void MakeAllNonDefault()
{

    try
    {
        QueryExpression query = new QueryExpression("customer");
        query.ColumnSet = new ColumnSet("defaultcustomer");

        EntityCollection retrieved = service.RetrieveMultiple(query);

        foreach (Entity myCustomer in retrieved.Entities)
        {

            myCustomer["defaultcustomer"] = false;
            service.Update(myCustomer);
        }

    }
    catch (Exception ex)
    {
        throw new InvalidPluginExecutionException("An error occurred in MakeAllNonDefault(): " + ex.ToString());
    }
}

ERROR:
It throws error on this line:

myCustomer["defaultcustomer"] = false;

System.Collections.Generic.KeyNotFoundException: 
The given key was not present in the dictionary. 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:19:39+00:00Added an answer on June 1, 2026 at 3:19 am

    The error means that particular field is not present in the collection of properties. In CRM, only properties that have been set or updated are included.

    Try something like:

    foreach (Entity myCustomer in retrieved.Entities)
    {
        if (myCustomer.Attributes.ContainsKey("defaultcustomer"))
        {
            myCustomer["defaultcustomer"] = false;
        }
        else
        {
            myCustomer.Attributes.Add("defaultcustomer", false);
        }
        service.Update(myCustomer);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CRM FetchXML string. This has a linked entity which means the
I have been asked to develop a new, small, custom-specific CRM (Customer Relationship Manager)
I am new to Microsoft Dynamic CRM. I have a .NET Winforms application which
We have a new client who would like us to develop a custom CRM
Do I need to save newly created CRM-entity instances before I can set relations
I am creating a new entity in CRM 4.0 to track our projects. One
We've recently created a new deployment in our CRM Dynamics 4 environment. In this
I want to add new field on my custom form. It should be 'Lookup'
Say you have an simple CRM system with customers and orders. If a customer
I've added a custom attribute (custom_contacttype) to the Contact entity. This attribute is of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.