Dynamics 365 - Uninstall CDS Solution from CRM Instance - Create Invoice Button Missing on Order Form

Hi All,

When we delete the managed CDS solutions from the D365 Sales instance, the D365 instance doesn't get reverted back to its OOB state.

We will notice that Create Invoice Button is missing from the Order form. And Submit Order button still remains present on the order form.

The issue is because of the "IsSOPIntegrationEnabled" attribute setting on  Entity "organization" .

When the CDS solution is uninstalled for integrating Sales and Fin Ops systems, the following changes are still present:

1. Boolean Attribute IsSOPIntegrationEnabled on Entity "organization" sets to true.
2. ‘Create Invoice’ button on the Sales Order ribbon is replaced with a ‘Submit Order’ button
3. ‘Submitted Status’ fields on the Sales Order entity is enabled.

D365 Sales instance can't be changed back to its OOB solution by UI configurations or customizations. The only solution to revert back the CRM instance to OOB solution is by making code changes.

Please find below the code :

using System;
using System.Net;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Tooling.Connector;

namespace ResetOrganizationSetting_OrderSOPIntegration
{
    class Program
    {
        static void Main(string[] args)
        {
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

CrmServiceClient crmSvc = new CrmServiceClient("<UserName>", CrmServiceClient.MakeSecureString("<Password>"), "<CrmRegion>", "<OrgName>", useUniqueInstance:false, useSsl:false, <orgDetail>, isOffice365:true);

            //CrmServiceClient crmSvc = new //CrmServiceClient("harvey.specter@suits.onmicrosoft.com", ConvertToSecureString("suits123"),  //"NorthAmerica", "suits", isOffice365: true);

            // Cast the proxy client to the IOrganizationService interface.

            using (OrganizationServiceProxy proxy = crmSvc.OrganizationServiceProxy)
            {
                EntityCollection organizationSettings;
                bool isSOPIntegrationEnabled;

                QueryForSOPSetting(proxy, out organizationSettings, out isSOPIntegrationEnabled);
                Console.WriteLine(string.Format("IsSOPIntegrationEnabled: {0}", isSOPIntegrationEnabled.ToString()));

                if (isSOPIntegrationEnabled)
                {
                    isSOPIntegrationEnabled = false;

                    Entity org = new Entity("organization");
                    org.Id = organizationSettings.Entities[0].Id;
                    org["issopintegrationenabled"] = false;

                    proxy.Update(org);                    
                }
                Console.WriteLine(string.Format("IsSOPIntegrationEnabled: {0}", isSOPIntegrationEnabled.ToString()));
            }
        }

        private static void QueryForSOPSetting(OrganizationServiceProxy proxy, out EntityCollection organizationSettings, 
            out bool isSOPIntegrationEnabled)
        {
            QueryExpression query = new QueryExpression()
            {
                EntityName = "organization",
                ColumnSet = new ColumnSet(true),
            };

            organizationSettings = proxy.RetrieveMultiple(query);
            isSOPIntegrationEnabled = organizationSettings.Entities[0].GetAttributeValue<bool>("issopintegrationenabled");
        }

        private static System.Security.SecureString ConvertToSecureString(string password)
        {
            if (password == null)
                throw new ArgumentNullException("missing pwd");

            var securePassword = new System.Security.SecureString();
            foreach (char c in password)
                securePassword.AppendChar(c);

            securePassword.MakeReadOnly();
            return securePassword;
        }
    }
}

Hope the code will help:

If you are getting below error:

Unable to Login to Dynamics CRMOrganizationServiceProxy is nullOrganizationServiceProxy is nullOrganizationServiceProxy is nullOrganizationWebProxyClient is nullOrganizationServiceProxy is nullOrganizationWebProxyClient is nullOrganizationServiceProxy is null

Solutions:
1. Check if you have the following statement written before connecting to D365 instance.
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
2. If the issue still persist, use the credential of "Global Admin" user
[Global Admin on O365 account; not System admin of D365 Sales]

Note:
The SOP Integration Mode also allows Orders created in Dynamics 365/CRM to be marked for integrating to an accounting system, using an integration tools (Scribe, SmartConnect, etc). This is done so that Invoice can be created only in Accounting/ERP system and synced to CRM system.





Comments

  1. Hi @Ramishwari Can you please help me out of 1 thing..

    I am unable to create invoice directly from the order can you please suggest the best possible solution.. Although I am using Data integrator for integration b/w CRM and FinOps.

    Thanks
    -SS

    ReplyDelete
  2. I will recommend anyone looking for Business loan to Le_Meridian they helped me with Four Million USD loan to startup my Quilting business and it's was fast When obtaining a loan from them it was surprising at how easy they were to work with. They can finance up to the amount of $500,000.000.00 (Five Hundred Million Dollars) in any region of the world as long as there 1.9% ROI can be guaranteed on the projects.The process was fast and secure. It was definitely a positive experience.Avoid scammers on here and contact Le_Meridian Funding Service On. lfdsloans@lemeridianfds.com / lfdsloans@outlook.com. WhatsApp...+ 19893943740. if you looking for business loan.

    ReplyDelete
  3. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    CRM with Invoicing

    ReplyDelete

Post a Comment

Popular posts from this blog

Microsoft 365 Cloud Offerings - Subscription & Licenses - Part 1

Common Data Service - Data Integration - Configuring Prospect to Cash - Part 4