Please!… Implement Different Behavior in Production versus Sandbox Dynamics 365 F&O Environments

Write code that behaves differently in production versus sandbox D365 environments.

As a customer/user, it can be a big problem when our customizations or ISV code does certain behavior like calling external web services or sending alert emails. Frequently, there’s some kind of configuration option to change that behavior: for example, a URL is stored in the database and can be changed through the GUI.

But, I can almost guarantee that every customer will be bitten at least once by doing a database refresh and accidentally sending test data out as though it was production data. Many administrators will eventually find themselves with a fairly lengthy checklist when they do a database refresh. For customers trying to do careful testing or frequent training, this can be time consumingt and possibly error-prone, even if automated as much as possible.

As developers, I feel we have an obligation to do more than meet the bare minimum of requirements; we should write code that is as easy as possible for end users, saving them time when possible. It should be a matter of professionalism, if not pride, for us. Therefore, I urge you to write code that can be configured once and will work the same in both sandbox and production environments.

How do we do that?… I recommend using a pattern with the GetUrl() method.

str prodAXUrlPattern = ''
str testAXUrlPattern = ''
str prodWebService = ''
str testWebService = ''

if (strContains(UrlUtility::GetUrl(), prodAXUrlPattern))
else if (strContains(UrlUtility::GetUrl(), testAXUrlPattern))
Throw error('This D365 environment has not been configured.');

Implementing something like this will require more work up front, but every administrator will thank you for foolproofing things against against costly mistakes.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: