In this webinar, our experts showcase a variety of demo use cases of how different components of the...
Did you know that you can programmatically update the definition of an entity in CRM using the UpdateEntityRequest class which contains the data that is needed to update the definition of an entity?
Here is a sample .net code that shows how to enable notes, queues, and disable mail merge on a custom entity named Lead Source.
using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Metadata; using Microsoft.Xrm.Sdk.Messages; using Microsoft.Xrm.Client.Services; namespace testconsoleapp { public class UpdateEntityDefnition { private void EnableNotesQueuesDisableMailMergeOnLeadSource() { RetrieveEntityRequest retrieveLeadSourceEntityRequest = new RetrieveEntityRequest { EntityFilters = EntityFilters.Entity, LogicalName = "po_leadsource" }; using (var service = new OrganizationService("CrmConnection")) { RetrieveEntityResponse retrieveLeadSourceEntityResponse = (RetrieveEntityResponse)service.Execute(retrieveLeadSourceEntityRequest); EntityMetadata leadSourceEntity = retrieveLeadSourceEntityResponse.EntityMetadata; // Disable Mail merge leadSourceEntity.IsMailMergeEnabled = new BooleanManagedProperty(false); //Enable Queues leadSourceEntity.IsValidForQueue = new BooleanManagedProperty(true); // Enable Notes UpdateEntityRequest updateOpportunityRequest = new UpdateEntityRequest { Entity = leadSourceEntity, HasNotes = true }; service.Execute(updateOpportunityRequest); } } } }
Where CRMConnection = the connection string to connect to the CRM org for which we are connecting to. That's it! Interested in learning anything and everything about Microsoft Dynamics CRM? Check out our Webinars on Demand, where you can watch great CRM content at any time!
Happy CRM'ing!