Dynamics NAV & the Copy Company feature

Sorry it's been so long since the last blog, lots going on in my personal & professional life has got in the way recently but I have renewed determination to share more.

So the copy company feature Microsoft added, in I believe 2016 2013R2 (thanks Natalie Karolak who has a better memory amongst other things, than me) , is just fantastic. While you need to be aware of the performance impact if you have a large dataset, the ability to 'spin up' a copy of your live data for testing is just ace and helps the support teams no end.

 

But, and you knew that was coming didn't you…..

It copies at SQL Level (which makes it as quick as possible) and that means there is no business logic applied. You get an exact duplicate of the copy your copying in that new copy.

Why is that a bad thing?

Well there are a number of issues and therefore things I believe you should either do yourself or get the system to do, after that copy.

Emails

The copy can send out email's. Not a problem in itself but click post & send as part of a test transaction and how is your customer or vendor supposed to tell that the email they get is not from your 'live' company. Getting good turning up against a purchase order number that's likely to be for a completely different vendor is going to confuse your goods in completely. Who is going to pay for the 'failed delivery'?

Best to go and take out the SMTP mail server's IP address – that stops any possibility. If you need to test the email function you can always go and put them back in for the short period you need to test its working correctly.

CRM Integration

So you have the link to Dynamics CRM configured, do you want the updates from you new company flowing through? It would really mess up CRM if those test accounts and product you create get replicated wouldn't it? Better turn it off then hadn't we.

 

Job Queue & Scheduled Tasks

So now there is no need to start separate NAS for each company for the Job Queue to start running. It run by the middle tier service for all companies by default. That means the job's that ran in live will also run in the new copy you've just created. That at best uses resources for no benefit and at worst sends loads of data or reports out that will confuse everything.

So after your copy remember to go into the job queue and place all the job queue entries 'on hold' – you can then enable the ones you need to run when you need them.

With 2017 the Job Queue creates scheduled tasks, I'm also deleting all of those to make sure nothing executes that I'm not in control of.

 

 

Company Information

So we have a fraud risk here. Imagine if I have malicious intent and I copy your live company, create a nice large sales invoice then immediately delete that company again. If that invoice is used in a VAT claim by another company, how are the tax authorities going to look at you? Say I raise and send a nice large purchase order to a vendor that then manufactures those items specifically for this order. How will you sort that out.

The Name in the company information should always be changed to make it clear it's not the 'live' company. I like a large '*TEST*' at the start of the company name. I also clear the VAT Reg. No and the Registered Company Number field as well.

In fact I like the company name to tell me the date & time I copied this company & from where, that way I know when this data was created and how up to date the data is. That means I know if I can delete it safely which is a must if I'm not to end up with lots of 'test' companies using lots of space and resources.

No. Series

I like to change the No. Series on my copy company as well to make it doubly sure contractual business documents cannot be misunderstood. If that Purchase Order has a number of '*TEST*PO00001' it would make even your dimmest vendor ring up and check.

 

Don't we just love Events

So all this is lots of effort and I have to remember to do it, wouldn't it be better if the system 'just did it' for me?

Well we have a Company table and thanks to Microsoft's new development capabilities, an 'OnAfterInsert' event for that table.

So I can write a function on a custom codeunit and subscribe to that event. That means it will run my code, after its does the copy company function in the Companies page.

So on github there's a codeunit that, if you renumber (its 50000 currently), then import & compile, will make sure all of the above are done, automatically for you, every time you copy a company.

And because it's an event subscription there are no changes to standard code. You know, every time I say that phrase to myself (and its all the time these days), I just want to whoop like an American!

Have I missed anything?

I'd be very grateful if anyone could suggest anything I've missed? Feedback is most welcome.

 

 

Author: James Crowter

I’m passionate about how businesses can improve their efficiency by getting process optimal more of the time. For the last twenty five years I’ve worked to help organisations of all sizes and types implement the ERP & CRM software that typically they decide they need when things are going wrong. I’ve seen that work unbelievably well and enabled those organisations to rapidly grow but I’ve also had some hard projects over that time where it’s felt more like warfare at times. Since 1996 (and version 1.01) I’ve been working with a small Danish product called Navision that’s now become Microsoft’s Dynamics NAV and I’ve also been using and consulting around Microsoft CRM since 2005. As managing Director of one of the longest established first Navision and now Microsoft Dynamics partners I’ve been involved in the complete history including numerous product councils and system design reviews. It’s my privilege to know many of the key Microsoft executives and product designers and have insight into both where the products are now and their future direction. So colleagues & clients have asked me to start this blog to share some of the insight that both this knowledge (obviously where not restricted by NDA’s or client confidentiality) and experience can help. Specifically I want to concentrate not on the specifics of how (there are some great blogs already for that) but why. If any user helps their business make better decisions or consultant can give better advice then that will be objective achieved. I founded Technology Management in 1992 and have led from the front ever since. Helping clients use technology to grow their business is my passion through explaining technology in terms that everyone can understand. My interest in computing began at the age of eight, long before my school had the equipment to cope. Throughout school and university I developed software commercially. I hold many IT certifications, such as Microsoft Dynamics NAV (for over 17 years), Microsoft Dynamics CRM (for over 10 years), as well as Microsoft Windows Server, Exchange and SQL. In October 2015, I was awarded the title of Most Valuable Professional (MVP), a title given to a select few individuals (31 currently) across the world specifically for Dynamics NAV. After years of working with a range of distribution and manufacturing software for hundreds of organisations, I focus on understanding the business requirements of an organisation, what it will take to deliver the systems required to maximise their potential. Follow me online via my other social channels: - Twitter: @jamescrowter - LinkedIn: linkedin.com/in/jamescrowter Or email me directly at james[.]crowter[@]tecman.co.uk.

4 thoughts on “Dynamics NAV & the Copy Company feature”

  1. Hi James,
    How can anyone live without this one?
    I was just about to create one my self for a project I’m working on right now, so thanks. I used to have a similar one in the classic versions – had to be manual run though. This is much better – love events.
    I would also change any path’s to integrations, like banking (epay etc.), OIOUBL/e-Invoicing, so that any exported e-invoices etc. are not put in the folders where they automatically get transferred. Ideally it would create the new “test-folders” on the go.
    Would also clear any “secure” user names and passwords. 
    Have you considered a way to run the same functionality, if you do a full “environment” copy? Like if you have just made a full copy of your production environment to a new training environment.
    Rgds,
    Erik

  2. Thanks Erik, glad its of use.
    Agree that its just a start and there may be many other changes that you should add, I wanted to keep it as ‘standard’ as possible but your right, banking is a standard area that I should definitely ‘turn off’.
    The full environment copy is an interesting one that had crossed my mind, checking the database name in a codeunit 1 event and if it’s not the same and the previous time CU1 ran should trigger the same changes across all companies. Soon as I get a few minutes I’ll put it together.

  3. Very useful. I did need to make one change to the code downloaded as it failed on the ChangeCompanyInfo() method where it tried to GET a blank record.
    LOCAL ChangeCompanyInfo(NewCompanyName : Text[30])
    // Old code
    // CurrentCompanyInformation.GET;
    // NewCompanyInformation.CHANGECOMPANY(COMPANYNAME);
    //New code
    CurrentCompanyInformation.GET(COMPANYNAME);
    NewCompanyInformation.CHANGECOMPANY(NewCompanyName);

Leave a Reply

Your email address will not be published. Required fields are marked *