For more info on managing identities in Dynamics CRM, see my presentation to the MIM Usergroup
I want to add a couple of new custom attributes to the Account and Contact entities. I want the attributes to start with a prefix of “tlk”. I also want to be able to access these attributes from C#
Add “tlk” prefix to the attributes
OOB, Dynamics will a prefix of “new” to any custom attribute. In other to specify your own prefix, do this
1. Create a new Publisher:
a. Navigate to Settings > Customizations, and select Publishers from the list.
b. Click the New button.
c. Provide a display name [TLKPublisher], and specify the prefix [tlk] you would like to use. Note that the Option Value Prefix number will be generated automatically.
d. Click Save and Close.
2. Create a new Solution:
a. Navigate to Settings > Solutions, and click the New button.
b. Provide values for Display Name [TLKPublisher] and Version .
c. In the Publisher lookup field, select the publisher you created in step 1 above.
d. Click Save and Close.
3. Add the entities to the solution that you want to add custom attributes to using the new prefix:
a. Open the solution from step 2, and click the Add Existing button.
b. Select the entities [Account and Contact] you would like to include, and click OK.
c. Expand Entities, expand the entity you want to modify, and click Fields.
d. Click New. You will notice here that your new prefix is now being used.
e. Create your custom fields and click Save and Close.
f. Click Save and Close to save the Solution. Note that you may need to click the Information tab in the upper-left corner so the Save and Close button becomes visible.
4. Publish customizations by going to Settings > Solutions, and click Publish All Customizations.
Generate updated metadata – Early bound classes
- Download the latest CRM SDK
- Open a command prompt, cd to the location of the bin directory. For me
- A location to store the generated file.
- A file name [TLK.XRM.cs]
- CRM Soap Webservice url
- CRM SysAdmin account and Password
- While you can add a namespace, I prefer not to, makes it easier for me manage
- Run the following command
CrmSvcUtil.exe /url:http://MyCRMServerName:5555/TLKCRM/XRMServices/2011/Organization.svc /out:C:\Documents\TLK.XRM.cs /username:”tlkenterprise\mycrmadmin1″ /password:”MyPassword” /serviceContextName:ServiceContext
Add generated metadata to C#
- Copy the TLK.XRM.cs to the CRM solution.
- Open your CRM solution in VStudio, click add existing item, select the TLK.XRM.cs.
- If you have the default generated metadata cs file, exclude it from your CRM solution.