Skip to main content

Finding differences in code layers between installation

When working with customizations in Dynamics AX I consider it best practice to have several installations for the same customer.

At a minimum you should have a development environment, a development test environment, a test environment besides the production environment that the customer runs in daily business.

DEV.
The development environment is for hacking away, developing and doing research and experiments.

DEV TEST.
The development test environment is for testing the customizations (inhouse QA) before releasing it to the customer for test.
The transfer of customizations between DEV and DEV TEST is done by exporting and
importing .xpo-files.


TEST.
The TEST environment is where the customer makes acceptance test of customizations.
The transfer of code to the TEST enviroment is preferably done by copying layer (.aod)-files from the DEV TEST to the TEST, allowing for release/build control.
If successive deliveries must be done, this can be again be done by exporting importing code AS LONG AS YOU ENSURE EXPORTING AND IMPORTING IS DONE WITH ID'S AND LABELS using an outer layer.

By doing the above described, you avoid having ID-conflicts, when doing RELEASE-upgrades.
A release/buld can the be delivered by copying the .aod and label-files from the DEV TEST to the TEST, and deleting outer layers where successive test-deliveries have been made. Thus when you deliver a release/build you have all customizations rolled up in the layer you use for release.

PRODUCTION.
When making a delivery to the production environment, this is preferably done by delivering layer-files. Again succesive deliveries for hotfixes can be done, by observing the above mentioned rules for the TEST environment (exporting / importing with ID'S and LABELS).


When working as a consultant you are sometimes challenged by having to take over a customer from someone else.
It can become even more challenging, if your predecessors have not been taking the above best pratice rules in to consideration, and you have doubts if the environments TEST and PRODUCTION are in synchronization.
Of course if recently deliveries have been made for test by the customer they wouldn't be.

But some times hotfixes are made directly in the production, and not carried back to the DEV and DEV TEST environments thus leaving the risk that the hotfix will be overwritten by a new release from the DEV TEST to TEST and further on from TEST to PRODUCTION.

I recently had this situation happen to me, and needed to get an overview of the differences between the layers in TEST and PRODUCTION.
Best practice was not followed in this case, so no DEV and DEV TEST enviroments were present, and hotfixes had been made directly in the production.

So I took the layers from the production environment and copied them to the appl / old folder under the TEST enviroment, and used a litte job to build a list of the differences.

Using this list, I was able to pull the code from the PRODUCTION missing in the TEST environment to the TEST environment, so that a release from the test environment weas made.

Se code below:


static void UtilElementsFindDiffInLayers(Args _args)
{
UtilElements newElement;
UtilElements uppElement;
UtilElementsOld oldElements;
UtilElements delElement;
UtilElementType type;
UtilEntryLevel level = UtilEntryLevel::cus;
Container types = [UtilElementType::TableInstanceMethod, UtilElementType::TableStaticMethod, UtilElementType::ClassInstanceMethod, UtilElementType::ClassStaticMethod];
UtilElementId uid = 0; //ClassNum(SysTableBrowser); // init UID if running on specific element
if running on specific element
boolean testMode = false; // TRUE to only test
Counter i;

type = conpeek(types,i);
while select newElement
order by utilLevel
where newElement.utilLevel > UtilEntryLevel::dip &&
(newElement.parentId == uid || !uid)
join oldElements
where oldElements.utilLevel == newElement.utilLevel
&& oldElements.name == newElement.name
&& oldElements.recordType == newElement.recordType
&& oldElements.parentId == newElement.parentId
{
if (oldElements.source != newElement.source)
{
info(strfmt("Layer: %1 Difference: %2 %3.%4",enum2str(newElement.utilLevel),global::enum2Value(oldElements.recordType),xUtilElements::parentName(newElement),oldElements.name));
}
}
}


ATTENTION: As always - USE CODE AT OWN RISK.

Comments

  1. And you're sure it's "UtilEntryLevel::dip" ;-)

    ReplyDelete
  2. It seems I failed to mention the fact that I was working with Axapta 3.0. So yep, it is

    UtilEntryLevel::dip.

    In a Dynamics AX 2009 that's the same as

    UtilEntryLevel::sl1.


    In 2009 the layers are called

    SYS
    SYP
    GLS
    GLP
    HFX
    SL1
    SL2
    SL3
    BUS
    BUP
    VAR
    VAP
    CUS
    CUP
    USR
    USP

    In 3.0 they are called

    SYS
    SYP
    GLS
    GLP
    DIS
    DIP
    LOS
    LOP
    BUS
    BUP
    VAR
    VAP
    CUS
    CUP
    USR
    USP

    ReplyDelete

Post a Comment

Popular posts from this blog

Suppressing the infolog

Supressing the infolog is often useful in D365FO when augmenting code. When augmenting code using COC (Chain Of Command), you can have new code run either before or after the code you are augmenting. This means that any infolog-messages that the standard application code does, will be shown to the user, even if your augmentation supports a scenario where there must be no infolog-messages. How do you avoid the standard application infolog-messages ? To the rescue comes temporary supression of the infolog. The suppression consists of: 1) Saving the current infologLevel 2) Setting the infologLevel to SysInfologLevel::None 3) Run your code 4) Restoring the saved infologLevel to the infolog For example a table could have a validatewrite-method that validates that you are only allowed to use 3 out of 6 options in an enum-field, and you need to allow for a fourth one. Table a - validateWrite method: boolean validateWrite() {     Switch (this.enumField)     {     ...

Indicating mandatory field in a dialog (RunBase) class.

A classical problem is indicating that a field is mandatory in a dialog, when the field is not bound to a datasource/field in a datasource. Normally fellow developers will tell you that, that is not possible. I found a way to do this. In your Runbase-based class you can implement the putToDialog-method e.g like this: protected void putToDialog() { super(); fieldMask.fieldControl().mandatory(true); } where fieldMask is a DialogField object in your dialog. This will make the field act like it was a mandatory field from a datasource in a form, showing a red-wavy line under the field, and requiring the field to have a value. Attention: Your class has to run on the client.If you set your class to run on the server, you get a run-time error, when the fieldMask.FieldControl()-call is made.

Dynamics AX 2012 ValidTimeState tables and form changing view from current to all

Valid Time State tables are new i AX 2012 a gives the developer the possibility to easily create tables that hold e.g. current setup data for various purposes, and at the same time keeping a "history" of the changes of the data in the table. For more reading: http://msdn.microsoft.com/en-us/library/gg861781.aspx I was tasked with doing a setup table with rates for calculating Vendor Bonus and I chose to base this a valid time state table. The customer asked for a button on the form, where you maintain the vendor bonus calculation setup data, so you could toggle viewing "Current setup" or "All setup" records (changing the view from actual to all records and vice versa in the form). I found that you can not change the ValidTimeStateAutoQuery property on the form data source in a form at run-time. It simply does not change anything, so I came up with the following solution: A boolean class member in the classdeclation method of the form: boolean ...