Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to reset Auto-numbering in Dynamics CRM Online


In past I have shown how to Reset auto-numbering un-supported way. Today I am going to discuss how we can reset auto-numbering by Microsoft supported way.

Number greyed-out so it can't be changed through UI. But we can write a small console application to update it using SDK.



Following code can be used to update the number. In this example I am updating CurrentKbNumber but we can also update CurrentCaseNumber, CurrentContractNumber, CurrentQuoteNumber, CurrentOrderNumber and CurrentInvoiceNumber. However we don't need to worry about prefix and they can be updated through UI.

    // QueryExpression to Retrieve Organization
    QueryExpression qe = new QueryExpression("organization")
    {
        ColumnSet = new ColumnSet(new string[] {"organizationid", "name", "currentkbnumber"})
    };
    EntityCollection orgs = service.RetrieveMultiple(qe);

    if (orgs != null && orgs.Entities.Count > 0)
    {
        var org = orgs[0];
        var organizationId = (Guid)org["organizationid"];

        // Creating a new Object to update. Set the CurrentKbNumber to your desired number
        OrganizationorganizationToUpdate = new Organization { CurrentKbNumber = 100000, Id = organizationId};
        service.Update(organizationToUpdate);
    }    

Once updated, please Got to Settings > Administration > Auto-numbering to verify.

Happy Coding

P. S. Hayer



This post first appeared on Dynamics CRM, please read the originial post: here

Share the post

How to reset Auto-numbering in Dynamics CRM Online

×

Subscribe to Dynamics Crm

Get updates delivered right to your inbox!

Thank you for your subscription

×