воскресенье, 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!

четверг, 7 июля 2016 г.

Lookup with possibility to choose color AX 2012

Hi to all!
Recently I've found kind of interesting piece of code, which allows us to choose color for row from Parameters form. You could use this parameter anywhere you want\need.
I just wanted to save this code for myself and then thought "It'd be unfair not to share it".
So, I'm going to share this code with you, hope it'd be helpful for you in your apps!

First of all, we need to create Int control on form with next properties
ColorSheme: RGB
Background color : black
Foreground color : black
Label foreground color (optional) : black
Choose datasourse and datafield if you want save this value in table

Override lookup method for this ds field\control and write next code:

public void lookup(FormControl _formControl, str _filterStr)
{
    Binary customColors;
    int             r, g, b;
    container       chosenColor;
    [r, g, b]   = WinApi::RGBint2Con(MCROrderParameters_CancelledLineColor.backgroundColor());
    chosenColor = WinApi::chooseColor(element.hWnd(), r, g, b, customColors, true);
    if (chosenColor)
    {
        [r, g, b] = chosenColor;
        MCROrderParameters.CancelledLineColor = Winapi::RGB2int(r, g, b);
        MCROrderParameters_CancelledLineColor.backgroundColor(MCROrderParameters.CancelledLineColor);
    }
}

Also, for better UI for user you could also override modified method and write next one:
public void modified()
{       MCROrderParameters_CancelledLineColor.backgroundColor(MCROrderParameters.CancelledLineColor);
for change control color immediately.

That's all probably, hope it helps you sometimes!

пятница, 17 июня 2016 г.

What is the difference between Table.data() and buf2buf methods AX 2012


Hi all,
while creating a duplicate or copy of a record , generally we use table.data() method , for passing each  field one by one. The only problem with data() method is it would copy the system fields  also line ModifiedBy, CreatedBy etc, hence if we are inserting data across companies , we can't use data() method.

So what should be the solution for this?
Dynamics Ax also provides one more generic method buf2buf(_SourceRecord,_TargetRecord) , the only difference between Buf2Buf() and data() method is that buf2buf() doesn't copy system fields, which we need :-) 

So for intercompany data inserting, we should use buf2buf() method with changeCompany() method.

Looking forward to your comments.

среда, 9 декабря 2015 г.

How to hide ranges in query for dialog RunBase

I've got the same problem. 

And untull today I resolve this problem by adding 

qbr.addrange()  for index fields on table and after that make them dissapear throgh 

qbr.rangestatus(RangeStatus::Hidden).

But today I found new solution for hiding index fields as ranges in dialog.


All you need it override showIndexFields() method and depend on what ranges in datasource(table) you want to hide, you must return false for those ones.


Here's an example

public boolean showIndexFields(TableId id)
{
    boolean ret = true;
    switch (id)
    {
        case tableNum(DirPerson) :
            ret = false;
            break;
        case tableNum(HcmEmployment) :
            ret = false;
            break;
    }
    return ret;
}

If you'll have any questions, please , send an email, I'll be happy to answer on them!

пятница, 29 мая 2015 г.

How to insert record in the end of the grid

Hello everyone!
I want to share with you some useful information.
I need to insert new records in the end of the grid. The DAX standatd behaviour's don't let this.
So I have found solution, how to do this.
Here's code, you just need to override create method on needed datasource:

public void create(boolean _append = true)
{
    this.last();
    super(_append);
}

The mose important in this code -  _append property.
By default it has false value, but we need to change it on "true"  otherwise our code won't work.

Please, if you have any questions - comment or send me e-mail!
Thanks!