Показаны сообщения с ярлыком AX365. Показать все сообщения
Показаны сообщения с ярлыком AX365. Показать все сообщения

понедельник, 19 июня 2023 г.

Convert set to container X++

Recently I've faced with a task - I had two sets and I need to check item by item for both of them to identify number of common values. Going with Enumerator or Iterator would be the obvious way. However, I wanted to eliminate of ambiguous code and found different way. I converted SET to Container and checked elements one by one. Maybe it's not the best solution from performance standpoint (yes, I'm aware of slowness of containers), but it's the simplest one. So, the actual conversion of the Set to Container I did via next code:

Set incomeSet = new Set(Types::String);
cntainer outputCon;
//filling in set.
outputCon = condel(incomeSet.pack(), 1,3);
The
condel()
funciton deletes all special symbols and other staff and in the end you'll get something like that:

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