Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Monday, February 25, 2013

How to publish all customization in CRM 2011 using .NET C#

I am developing a tool that creates attributes on runtime and I need to publish all the customization’s and for this purpose I am just exploring SDK and found this message request
"PublishAllXmlRequest" which is used to publish all customization in CRM 2011 here is the complete syntax I hope it help’s some one
J

PublishAllXmlRequest publishReq= new PublishAllXmlRequest();

service.Execute(publishReq);

Note: Make sure you have added a namespace Microsoft.Crm.Sdk.Messages;

Thanks

Tuesday, January 22, 2013

Using ExecuteMultipleRequest with CRM 2011

ExecuteMultipleRequest METHOD IN ACTION

As we all know CRM 2011 rollup 12 has lunched a new ExecuteMultipleRequest method.
Today i am just exploring this great feature and develop a code snippets and wants to share with you.
Note: Make sure you have latest SDK of CRM 2011

            var service = new XrmServiceContext("Xrm");
            OrganizationRequestCollection collection = new OrganizationRequestCollection();
            for (int i = 0; i <= 5000; i++)
            {
                CreateRequest createRequest = new CreateRequest // create a request and add the request in collection
                {
                    Target = GetEntityRecord()    // this method could returns any entity i.e account, contact etc you could implement your own logic to get the target entity
                };
                collection.Add(createRequest);
            }

            ExecuteMultipleRequest excuteMultipleRequest = new ExecuteMultipleRequest // Create ExecuteMultipleRequest object with the above collection
            {
                Requests = collection,
                Settings = new ExecuteMultipleSettings
                {
                    ContinueOnError = false,
                    ReturnResponses = true
                }
            };
            ExecuteMultipleResponse executeMultipleResponse = (ExecuteMultipleResponse)service.Execute(excuteMultipleRequest); //Execute the request
            var results = executeMultipleResponse.Results; //Request result


I hope it helps some one.