Dynamics 365





Thursday, January 28, 2016

Export MSCRM 2015 Solution with required components

Import and export Micro Soft CRM 2011 or 2013 or 2015 solution with required components.

when ever we need the export or back up our solution with all our work including unmanaged entities we can take the backup and we can export in any other environment.
 
we may get error message saying "Missing required Components". in while exporting the solution like below.





Please follow below steps to add required components .

1)  select each component and click on add required components.
2) still you are getting same error message Missing required Components" check which entity is missing in dialog.
3) Remove it from components list and add again by choosing below check boxes.
1)Include entity metadata 2) add all assets check both.

4) next step it will ask for include all required components - please select 1 st option.(include all required components)



5) then repete steps until you add all required components

then
you will get below window.
 

 then export and save the solution.

Thanks
Murthy


Friday, November 20, 2015

delete crm record using c#

 Delete CRM record using c#.


 protected void HCIF_Click(object sender, EventArgs e)
        {

            string connectionInfo = "http://crmXXXXXXX/XXXXXXXXXs/XRMServices/2011/Organization.svc";
            string userName = "crmadmin";
            string passWord = "XXXXXX";
            string domain = "APPS";

            ClientCredentials credentials = new ClientCredentials();
            credentials.Windows.ClientCredential = new System.Net.NetworkCredential(userName, passWord, domain);

            //System.Net.CredentialCache.DefaultNetworkCredentials;
            Uri homeRealUri = null;
            Uri organizationUri = new Uri(connectionInfo);
            //This ServiceUri will be taken from web.config later.
            //ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(CustomXertificateValidation);
            using (OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealUri, credentials, null))
            {
                try
                {
                    string HCIF = TextBox1.Text.ToString();
                    //_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
                    //_serviceProxy.EnableProxyTypes();

                    IOrganizationService _service = (IOrganizationService)_serviceProxy;
                    _serviceProxy.Timeout = new TimeSpan(24, 60, 18);

                    OrganizationRequest req = new OrganizationRequest();

                 
                    //StringWriter stringWriterRes = new StringWriter();
                    //XmlSerializer serializerRes = new XmlSerializer(typeof(Entity));
                    //serializerRes.Serialize(stringWriterRes, _service);

                    string fetchXml =
              @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' >
                        <entity name='new_cif'>
                           <attribute name='new_cifno' alias='HCIF' />
                            <filter type='and'>
                            <condition attribute='new_cifno' operator='eq' value='{0}' />
                            </filter>
                        </entity>
                      </fetch>";

                
//  fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
//                                <entity name='new_cif'>
//                                <attribute name='new_cifno' />                            
//                                <filter type='and'>
//                                    <condition attribute='new_cifno' operator='eq' value='{0}' />
//                                </filter>
//                                </entity>
//                            </fetch>";
             

                string formatXml = string.Format(fetchXml, HCIF);
               FetchExpression fetchexp = new FetchExpression(formatXml);
                // Fetch the results.
               var EntHCIF = _serviceProxy.RetrieveMultiple(fetchexp);


               if (EntHCIF.Entities.Count > 0)
               {
                   bool isDel = false;

                   foreach (var ent in EntHCIF.Entities)
                   {
                       _serviceProxy.Delete(ent.LogicalName, ent.Id);
                       isDel = true;
                   }
                   if (isDel)
                       Label1.Text = "Deleted HCIF Successfully.. with HCIF:" + HCIF + "...nunmber of HCIFs found.." + EntHCIF.Entities.Count;
               }
               else
                   Label1.Text = "HCIF NOT FOUND..";

            

                }
                catch (Exception ex)
                {
                    string err = ex.Message;
                    Label1.Text = err;
                }
            }
        }​