четверг, 10 августа 2017 г.

Get contact info from site address


Hi fellows!

Recently I h ave had some difficults to get contact information from Site address and I did searching at least 2 days.
I tried tu use many different approaches, some of them was to complicated, some not, but all was not working unfortunately.

But today I found working ( I guess) way.
Here's the code how to get contact information from site address (either phone, email, url and so on). For my case it was Phone:

    LogisticsEntityPostalAddressView     postalAddressView;
    LogisticsElectronicAddress                  electronicAddress;
    LogisticsLocation                                 contactLocation;

    inventLocation = inventLocation::find(ShipmentTable.InventLocationId);
    if (inventLocation)
    {
        select firstonly postalAddressView
            where   postalAddressView.Entity     == inventLocation.RecId
            &&      postalAddressView.EntityType == LogisticsLocationEntityType::Site
            &&      postalAddressView.isPrimary  == NoYes::Yes;

        if (postalAddressView)
        {
            select firstOnly electronicAddress where electronicAddress.Type == LogisticsElectronicAddressMethodType::Phone
            join contactLocation where contactLocation.ParentLocation  == postalAddressView.Location
                && contactLocation.RecId == electronicAddress.Location;

            info(strFmt("Primary contact name: %1  Primary contact phone: %2",electronicAddress.Description, electronicAddress.Locator));
        }

I tried and it worked! I improved query, because originally it has 2 selects instead of 1.

Hope it will be useful for someone!

Happy DAX-ing. :)
   


четверг, 6 июля 2017 г.

Update/delete InventDim (memorize)


Recently I've found during searching one interesting information that could be useful for anyone who develops in AX.
The information related to manipulation with data in InventDim table.

InventDim table is backbone of Dynamics AX Inventory management module
before deleting inventDim record using method inventDim.delete(true) you should do following validation
* There should not be any record in InventSum table related the InventDimID which you are going to delete
* There shuld not be any record in InventTrans table related to InventDimID whicu you are going to delete
before updating inventDIM record using method inventDim.update(true) you should do following validation
* ensure that inventTrans records related to inventDimID which is getting updated is good to get updated with new 'inventBatchId' and 'InventSerialId', otherwise you will have bad information is On-hand details
* ensure that inventDim table is not having any record with new combination is inventory dimension, otherwise it will not get update.
It is recommended that we should not do any outside update and  delete in InventDim Table, but if you will take care of above data intigrity checks then you can update and delete the records in InventDim Table with out any issue.


I hope these observations will be helpful :)

Happy DAX-ing !

понедельник, 27 марта 2017 г.

How to extend BaseEnum Ax7

Today I had some misunderstanding of extension concept. I just wanted to create an extension of NumberSequence, but couldn't do it.
After some investigation I found out that only those BaseEnums which have IsExtendible propety set to true are allowed to extend.

So bear this info in mind during create own enums or extensions from standard enums :)

Happy DAX-ing!

среда, 15 марта 2017 г.

Remove "Close" button from form

Hi All!

Today I found that I fogrot how the Close button could be hidden from standard AX form.
But after google helped me and I share with you this information:

All you need to do is set the "Status bar style" property to SimpleWithoutClose.

And that's it :) Profit.

воскресенье, 26 февраля 2017 г.

Event handler for form datasource ax7

Hi, dear readers!
Recently I've had new task for Ax7, namely, I had to change behavior of one control on form. For this I must not customize current form, but extend it and create event handler to handle it. This was I done.
And below I just wanted to share with you some thoughts about  how we could do it faster and easier:

[FormDataSourceEventHandler(formDataSourceStr(WHSShipmentDetails, WHSShipmentTable), FormDataSourceEventType::Activated)]
    public static void WHSShipmentTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        WHSShipmentTable    shipmentTable = sender.cursor();  // our Args.record()
        //FormDataSource      shipmentDs = sender.formRun().dataSource(tableNum(WHSShipmentTable));      // in that way we could get DataSource to manipulate ds fields for example.
        FormControl         printConfirmControl = sender.formRun().design(0).controlName("ConfirmAndPrintShipmentRun"); //get control to change behavior
                printConfirmControl.enabled(WHSShipConfirm::isShipConfirmEnabledForShipment(shipmentTable));
    }

After creating new class, build the project and verify whether your event handler works or not.

Hope it'd be helpful!

Looking forward to seeing with you in new posts!



среда, 28 декабря 2016 г.

How to run client with particular AOS



Recently I had a task to run AX with particular AOS on the same machine. It has 2 aos installed.
But I don't have access to Configuration utility.
So, I thought that there's a way to run ax without shortcut, but with cmd.

I goggle and found a solution which works exactly I need:

1. Open cmd  (no matter with Administration privilegy or without).
2. Go to C:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin (the path may be different , it depends on Ax version.
3. Run AX32.exe with following parameters:
-loadbalance=0 -aos2 = "your aos instance name"
4. Press Enter.

Profit!

вторник, 4 октября 2016 г.

How to add new document into print management module

Hi All!
Recently I've faced with task which I've never done before. It's adding new document into print managment settings for certain module (in my case it was WHS module).
I tried to found any solution or advice in web but it was unsuccessfully.
Finally I found some advice regarding my issue but is was written not so good as for me.
And I decided to keep this solution in my blog so here're we go:

Lets asume that we want to add new document with "DocName" into our print management settings.

What we should do for this?
1) Go to Data Dictionary -> Base enums ->  and find PrintMgmtDocType.
2) Add new enum into this base enum with name "DocName"
3) Go to Classes -> PrintMgmtDocType
4) Find method getDefaultReportFormat()  in this class and add new case statement into it for our enum
5) Add appropriate tableId and FieldId into getQueryRangeFields() and getQueryTableId()  methods for further treatment
6) Next, add a case statement to the method getDocumentTypes() of the class PrintMgmtNode child class, i.e. PrintMgmtNode_CustTable or PrintMgmtNode_Sales or whichever node you want to add it to in the print management hierarchy. In our situation it was class WHSPrintMgmtNode_WHS.

After that you could see your document under WHS print management module settings.
But the thing is you won't be able to add Report  format value untill add it into PrintMgmtReportFormat  table manually (I haven't explanation of this yet).

After you added the value into this table - you'll be able to print your report.
Profit!