CRM2011 – Retrieve all Entities, Update and Publish them

I needed to change an property on all entities in my organitation. The unique way was to open all entites, modify the attribute, save and publish.. but it is a long and boring work and I don’t like this kind of job. I created a small console application that make it. In this article I will show you how to access items in CRM 2011 via new built in WCF webservice. The main code is the following:

IServiceConfiguration<IOrganizationService> orgConfigInfo =
ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri("http://server/Organization/XRMServices/2011/Organization.svc"));

//Set the credentials
System.Net.NetworkCredential userDefined = new System.Net.NetworkCredential("Username", "Password", "domain");

var creds = new ClientCredentials();
creds.Windows.ClientCredential = userDefined;

using (_serviceProxy = new OrganizationServiceProxy(orgConfigInfo, creds))
   RetrieveAllEntitiesRequest request = new RetrieveAllEntitiesRequest()
      EntityFilters = EntityFilters.Entity,
      RetrieveAsIfPublished = true
   // Retrieve the MetaData.
   RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse)_serviceProxy.Execute(request);

   foreach (EntityMetadata currentEntity in response.EntityMetadata)
      currentEntity.IsVisibleInMobile.Value = false;

      UpdateEntityRequest updateEntityRequest = new UpdateEntityRequest();
      updateEntityRequest.Entity = currentEntity;

   PublishAllXmlRequest publishRequest = new PublishAllXmlRequest();

I got all entities, I updated them and at the end I published all modified….. 🙂
The console application is on my Github repository (MsCrm.RetrieveUpdate.ConsoleApplication)


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di

Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...