Home » Microsoft Technologies

Dynamic Entity-Create Entities in CRM


                   I had created a dynamic entity and properties to it by using



na = newDynamicEntity();

na.Name =



StringProperty MyAccountName = newStringProperty();

MyAccountName.Name =


MyAccountName.Value =



newProperty[] { MyAccountName};


StringProperty MyAccountNo = newStringProperty();

MyAccountNo.Name =


MyAccountNo.Value =


na.Properties= newProperty[] { MyAccountNo};

                      when doing like this, only the last added propety is created in CRM( here, only accountnumber is saved in CRM)..I want to create an account  with the name 'Greg' and account number '1234596'...I can use

na.Properties= newProperty[] { MyAccountName,MyAccountNo};

But ,is there is any other alternative to do this?


19 Answers Found


Answer 1


first you need to decide you will use crmwebservice or crm  SDK for that.


Answer 2

Try to use easiest code:

DynamicEntity na = new DynamicEntity("account");

na["name"] = "Greg";

na["accountnumber"] = "123456";


Answer 3

Working with dynamic  entities is a bit different in 4.0 vs. 3.0.  When writing plug-ins and using Microsoft.Crm.Sdk, you have the ability to access the attributes of a Dynamic Entity via a property bag, much like this:

DynamicEntity updateEntity = new DynamicEntity("m3_roundrobin"); updateEntity["m3_lastuserid"] = newOwner.ToString(); updateEntity["m3_teamid"] = teamId.ToString();

However, if you're writing an application that used the standard crm  web service, this methodology is not available to you, so you have to resort to the more code-intensive methods we used in CRM 3.0

Fortunately, if you look deep into the CRM SDK, you'll find a solution to this issue.

After installing the CRM 4.0 SDK, browse to this folder:


and look for the following file:


If you add this file to your Visual Studio project, you will have the same Dynamic Entity property bag capability using the CRM web service as you do when using the Microsoft.Crm.Sdk assembly.

I was pleasantly surprised when I located the code and it has made working with Dynamic entities  much easier.


Source : https://community.dynamics.com/blogs/billoncrm/comments/61642.aspx


Answer 4

I had found 'dynamicentitypartialtype.cs' in  CRM 4.0 SDK..How can I add this file to my project?


Answer 5

rightclick on solution explorer, select Add existing item and browse dynamicentitypartialtype.cs file and click on add

Answer 6

But, In SDK, There is only the name  'dynamicentitypartialtype.cs'   and a description, I did not find a .cs..Pls help me



Answer 7

I think you are looking for a code with less lines.

This code does exactly the same as your example:


DynamicEntityna = newDynamicEntity("account");

na.Properties.Add(new StringProperty("name", "Greg"));

na.Properties.Add(new StringProperty("accountnumber", "1234596"));


Dejan Dular

Microsoft Certified Business Management Solutions Specialist

Answer 8

Hmmm, you will get this file under "sdk\server\helpers\cs\crmhelpers" location

Answer 9

I have CRM 4.0 installed in my machine and a CRM SDK 4.0.chm file..Is this is enough to find the file 'dynamicentitypartialtype.cs'?



Answer 10

DynamicEntityna = newDynamicEntity("account");

na.Properties.Add(new StringProperty("name", "Greg"));

na.Properties.Add(new StringProperty("accountnumber", "1234596"));

            This was not working in my page..(.Add) is not recognized..Also na["name"] is not recognized..I am using CRM web services.

              Why this happen?..Is there is any way to make it recognize?..(other than to install Crm 4.0 sdk and include 'dynamicentitypartialtype.cs')..pls help me..


Answer 11

Have you referenced microsoft.crm.sdk.dll and microsoft.crm.sdktypeproxy.dll?

Also check if your project is set to .net framework 3.5. Maybe this is an issue too.


Answer 12

Hey ,

When you will install crm  SDK, it will create a SDK folder , Under that you should get server\helpers\cs\crmhelpersdynamicentitypartialtype.cs  file


Answer 13

I had referenced to both microsoft.crm.sdk.dll and microsoft.crm.sdktypeproxy.dll..



                              But,still there is problem..How can I check my  project is set to .net framework 3.5?..


Answer 14

Is there is any solution to the problem without using dynamicentitypartialtype.cs  ?.   I am using Crm web services . dynamic  Entity is recognized in my page..But,Properties do not have the attribute Add.

 So, I can't use

DynamicEntityna = newDynamicEntity("account");

na.Properties.Add(new StringProperty("name", "Greg"));

na.Properties.Add(new StringProperty("accountnumber", "1234596"));


na["name"] = "Greg";

na["accountnumber"] = "123456";


                For, make use of the above codes, what can I do? pls help me 



Answer 15

dynamicentitypartialtype.cs is when you want to use crmservice reference, so other way is to use only MS crm  SDK, remove crm webservice reference and use only MS CRM SDK then you should be able to use like below

DynamicEntity _account = new DynamicEntity("account");



Answer 16

I am using Crm web service..So, I think the above dlls are not required..I need a solution for Dynamic Entity in Crm web service..pls help me keeping this in mind...What I actually want is an alternative to

na.Properties =

newProperty[] {MyAccountno,MyaccountName}

                       Bcoz, I want to avoid 'comma'...


Answer 17

Hi Hari,

You can not use the above code when you are working with MS crm  Web Service.

Use below code:



na = newDynamicEntity();




StringProperty accountName = newStringProperty();






StringProperty accountnumber = newStringProperty();






newProperty[] { accountName, accountnumber};



Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM Consultant

na.Properties =

accountnumber.Value =

accountnumber.Name =


accountName.Value =

accountName.Name =



na.Name =


Answer 18

Ranjit he has already mentioned he don't want to use this approach  :)

na.Properties =


newProperty[] { accountName, accountnumber};

Hari : I am not getting you why you are not able to add this file, if you are not getting this file I will suggest you to download CRM SDK and install and get this file



Answer 19

Thank you all,especially Mahain

                                         I think, and now got an alternative..which is ,

na.Properties =


   So,by incrementing 'i', I am able to enter both the properties

if i=0;

 na.Properties[i] = MyAccountName;

if i=1;

na.Properties[i] = MyAccountNo;

                                      The problem is fixed.



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure