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)     {         boolean ret;         case

Dynamics ax 2012 traversing selected records in a form data source

A classical developer challenge in Dynamics AX is to enable a form button when multiple records have been selected in the form by the user. This usually involves writing some form of loop (for or while or do-while) that starts out with calling _ds.getFirst() and continuing the loop as long as _ds.getNext() returns a tablebuffer. Well things got a little bit easier in AX 2012. In AX 2012 you can use the MultiSelectionHelper class. One example is the following that I encountered in AX 2012: Can you make the customer collection letter print out run for each selected collection record in the Print/Post collection letters form (Accounts receiveable / Periodic / Collections / Print/Post Collection letters). If we ignore the possibility for setting up print destination for running each report we can do this in two steps: 1) Change the "Multiselect" property of the "MenuButton" and the "Menuitembutton" in the MenuButton in the form from "Auto&quo

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.