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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

The specified type 'Plugin.contact' is not a known entity type.

(0) ShareShare
ReportReport
Posted on by

I am writing a plugin for Invoice Entity. I need to update a field in invoice using contactid from contact entity.

I used early bound generator to get entities and writing Linq query to fetch the field value  from contact entity using the relationship between invoice and contact. 

I am getting below error.

The specified type 'Plugin.contact' is not a known entity type.

can anyone help.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mamatha Swamy Profile Picture
    5,426 on at
    RE: The specified type 'Plugin.contact' is not a known entity type.

    Check this post

  • Community Member Profile Picture
    on at
    RE: The specified type 'Plugin.contact' is not a known entity type.

    Thanks. But the early bound generated cs already has this reference.

  • Aileen Gusni Profile Picture
    44,524 on at
    RE: The specified type 'Plugin.contact' is not a known entity type.

    Montek,

    Can see your command to generate the early bound and your snippet?

    Thanks.

  • Community Member Profile Picture
    on at
    RE: The specified type 'Plugin.contact' is not a known entity type.

    Hello Aileen,

    i used the Early Bound generator XRMBOX tool.

    My snippet

    protected void ExecutePreInvoiceCreate(LocalPluginContext localContext)

           {

               if (localContext == null)

               {

                   throw new ArgumentNullException("localContext");

               }

               IPluginExecutionContext context = localContext.PluginExecutionContext;

               IOrganizationService service = localContext.OrganizationService;

               if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)

               {

                   Entity entity = (Entity)context.InputParameters["Target"];

                       if (context.MessageName == "Create")

                       {

                           //Code to be executed during Create event of an entity

                           try

                           {

                               Guid guidContactID = Guid.Empty;

                               guidContactID = ((EntityReference)entity["customerid"]).Id;

                               using (ServiceContext svcContext = new ServiceContext(service))

                               {

                                   var registryNumber = (from m in svcContext.ContactSet

                                                         where m.ContactId == guidContactID

                                                         select new Contact

                                                         {

                                                           New_RegistryNumber = m.New_RegistryNumber

                                                        });

                                   foreach (var c in registryNumber)

                                   {

                                     if (entity.Attributes.Contains("new_customernumber"))

                                       {

                                           entity.Attributes["new_customernumber"] = c.New_RegistryNumber;

                                       }

                                      else

                                      {

                                          entity.Attributes.Add("new_customernumber", c.New_RegistryNumber);

                                      }

                                  }

                               }

                               }  

                           catch (FaultException ex)

                           {

                               throw new InvalidPluginExecutionException("An error occurred in the Invoice Create plugin:-", ex);

                           }

                       }            

               }

           }

  • Suggested answer
    Aileen Gusni Profile Picture
    44,524 on at
    RE: The specified type 'Plugin.contact' is not a known entity type.

    Montek,

    I don't see any weird thing in your code that referring to contact.

    Are you using ILMerge?

    if yes please refer to these posts

    nishantrana.me/.../the-specified-type-is-not-a-known-entity-type-error-while-using-early-bound-entity-classes-in-crm-2013

    social.microsoft.com/.../how-to-make-the-crm-2011-plugin-detect-types-from-early-bound-organisation-class

    Thanks.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans