Answered by:
Creating records for custom entities in c#

Question
-
Hi there,
I am new to Dynamics CRM, and am currently trying to create a record for a custom entity called "Project". I have created the custom entity within CRM and have published the customizations. I am now trying to use C# to create a single record for the custom entity. I know I need to use a DynamicEntity, but I'm not sure how to use it. Could somebody point me in the right direction?
Thanks,
RoshanWednesday, September 2, 2009 8:31 PM
Answers
-
If you are not using plugin, and If you refresh the MS CRM Webreference then you will get EntityName.project.ToString()
or otherwise you can use this.
projectEntity.Name = "project"; // it is just a string
please the above is the schema name of your entity so it could be new_project (just make sure the schema name is correct) but defnitately it will not be project.
so your code will look like this (where new_project could be the schema name of your entity).
projectEntity.Name = "new_project";- Marked as answer by Roshan Mehta Saturday, September 5, 2009 3:50 AM
Wednesday, September 2, 2009 8:51 PM
All replies
-
Check this url for dynamic entity create
http://mscrm-developer.blogspot.com/2009/02/create-dynamic-entity-record.html
http://msdn.microsoft.com/en-us/library/cc151183.aspx
http://stackoverflow.com/questions/204488/creation-of-dynamic-entities-in-ms-crm-4-0
fore more on dynamic entity read these
http://www.shanmcarthur.net/crm/developers-corner/using-dynamic-entities
http://blogs.infinite-x.net/2008/08/01/working-with-dynamic-entities-in-crm-40/
http://community.adxstudio.com/Default.aspx?DN=d493fff7-e053-4b03-8137-b0ea32ed0b22
you can also use dynamic entity wrapper for create,update and other functions. see this
http://community.adxstudio.com/Default.aspx?DN=d493fff7-e053-4b03-8137-b0ea32ed0b22- Edited by Muhammad Ali Khan Wednesday, September 2, 2009 8:40 PM more info added
- Proposed as answer by Muhammad Ali Khan Wednesday, September 2, 2009 8:40 PM
Wednesday, September 2, 2009 8:37 PM -
Thanks for your reply,
What I don't understand in the first example is the line:
contactEntity.Name = EntityName.contact.ToString();
In my case, I assume it would be projectEntity.Name = EntityName.project.ToString();
but this cannot work since Visual Studio doesn't show me the "project" option in intellisense. How can I make it so Visual Studio knows of the existence of my custom entities?Wednesday, September 2, 2009 8:46 PM -
If you are not using plugin, and If you refresh the MS CRM Webreference then you will get EntityName.project.ToString()
or otherwise you can use this.
projectEntity.Name = "project"; // it is just a string
please the above is the schema name of your entity so it could be new_project (just make sure the schema name is correct) but defnitately it will not be project.
so your code will look like this (where new_project could be the schema name of your entity).
projectEntity.Name = "new_project";- Marked as answer by Roshan Mehta Saturday, September 5, 2009 3:50 AM
Wednesday, September 2, 2009 8:51 PM -
Hi roscoe,
Are you sure you need a dynamic entity? Dynamic entities are mainly used when you need to specify the entity type at runtime.
You will need to update your web reference (rclick web reference > update) in your C# project for this entity to become available through the web service.
Depending on your customization prefix ('new' being standard), your entity will be something like 'new_project'. The rest is identical to that of an existing entity.
hih,
Karlo
Karlo Swart - http://www.ver206.comThursday, September 3, 2009 8:51 PM -
Hi,
Have you found way to resolve it?
using
Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Proxy;
I have added a referece to these dll's in my VS project but then using them will not show me my custom entities which I have created within CRM. So, I added a web reference to my project so that i can create new records in my custom entities.
Basically I am creating a new record in one of my custom entity "new_accountchangehistory" to capture the change in "accountnumber" from account, whenever someone updates the accountnumber (from PostImage) I am inserting a new record in this custom enetity. My dll is registered to run on update of the account. For the first time whenever i update the accountnumber it captures and creates a record in my custom enetity but for my next update it does not create a record, instead it generate an exception.
Does any one has any idea why is that happening?
Is there anyway to create/update records in custom entity without having web reference?
CRM AnalystWednesday, September 30, 2009 2:25 PM -
Hi Rosco,
You need to add a web reference to your project.
Right click on the Reference in solution explorer in visual studio then select add web reference. You need to type this in the pop-up window
http://<crmservname>/mscrmservices/2007/CrmServiceWsdl.aspx?uniquename=<companyname>
give it a name. Make sure you have made the referece in your code to this web service.
Good luck.
CRM AnalystWednesday, September 30, 2009 2:32 PM -
Just update the CrmSdk web reference, that's it.
Regards
Sunday, August 22, 2010 5:52 AM