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)

"Could not find an entity with specified entity name: new_MyCustomEntity" Error While Creating Attribute

(0) ShareShare
ReportReport
Posted on by 3,355

Hello Experts,

I am trying to create  entity and attribute. so for this my code is like below.

private  void CreateEntity(ServerConnection.Configuration serverConfig,string entityName, OwnershipTypes ownerType)

        {

           

try

            {

               

using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri,

               serverConfig.HomeRealmUri,

               serverConfig.Credentials,

               serverConfig.DeviceCredentials))

                {

                    _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(

new ProxyTypesBehavior());

                   

// Create custom entity.

                   

CreateEntityRequest _entity = new CreateEntityRequest()

                    {

                        Entity =

new EntityMetadata

                        {

                            LogicalName = entityName,

                            DisplayName =

new Microsoft.Xrm.Sdk.Label(entityName, 1033),

                            DisplayCollectionName =

new Microsoft.Xrm.Sdk.Label(entityName, 1033),

                            OwnershipType = ownerType,

                            SchemaName = entityName,

                            IsActivity =

false,

                           

// IsAvailableOffline = true,

                           

// IsAuditEnabled = new BooleanManagedProperty(true),

                           

//IsMailMergeEnabled = new BooleanManagedProperty(false)

                        },

                       

// HasActivities = false,

                       

// HasNotes = true,

                        PrimaryAttribute =

new StringAttributeMetadata()

                        {

                            SchemaName =

"new_name",

                            LogicalName =

"new_name",

                            RequiredLevel =

new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.Recommended),

                            MaxLength = 100,

                            DisplayName =

new Microsoft.Xrm.Sdk.Label("Name", 1033)

                        }

 

 

                    };

                    _serviceProxy.Execute(_entity);

                   

PublishAllXmlRequest publishReq = new PublishAllXmlRequest();

                    _serviceProxy.Execute(publishReq);

        

                   

                }

            }

           

catch (Exception ex)

            {

               

MessageBox.Show(ex.Message+"\n"+ex.StackTrace);

            }

        }

// Code for Attribute Create

private void  CreateAttribute(string entityName)

        {

           

if (addedAttributes != null)

            {

               

foreach (AttributeMetadata anAttribute in addedAttributes)

                {

                   

// Create the request.

                   

CreateAttributeRequest createAttributeRequest = new CreateAttributeRequest

                    {

                        EntityName = entityName,

                        Attribute = anAttribute

                    };

                   

// Execute the request.

                    _serviceProxy.Execute(createAttributeRequest);

                   

//Console.WriteLine("Created the attribute {0}.", anAttribute.SchemaName);

                }

            }

        }

While creating attribute I am getting following error

Could not find an entity with specified entity name: new_MyCustomEntity

Server stack trace:

   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

 

Exception rethrown at [0]:

   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

   at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request)

   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)

   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request)

   at EntityCreation.NewEntity.CreateAttribute(String entityName) in d:\Saroj\EntityCreation\EntityCreation\NewEntity.cs:line 609

   at EntityCreation.NewEntity.btnCreate_Click(Object sender, EventArgs e) in d:\Saroj\EntityCreation\EntityCreation\NewEntity.cs:line 292

When I am checking CRM 2015 online, The entity is created. It was working fine. But now not working. Please suggest what might be the problem.

Best Regards,

Saroj

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Royal King Profile Picture
    27,686 on at

    Make sure entity name all in lower case letters. If  entity name  contains any upper case letter you may see this error message

  • Saroj Das Profile Picture
    3,355 on at

    Hi Chitra, Thank you very much for your valuable reply. You are absolutely correct that was my mistake. While creating attribute I was passing entity name which contains a capital letter in that. I rectified and worked fine.

    Thank you again Chitra.

    Saroj

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