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

понедельник, 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:

пятница, 18 мая 2018 г.

Check how many rows were selected on the form grid

Hi!

This approach is common for either DAX 2012 or D365FO.

If you need to check how many rows were selected by the user, you just need to get the formDataSource value before, for example

FormDatasource fds = _args.record().datasource();

And then write next code:
if (fds.recordsMarked().lastIndex() > 1)
{
    info("more than 1 record was selected");
}  

Hope, this information will be useful for someone as for me.

пятница, 22 сентября 2017 г.

Check if ItemId is serialized

Hi folks!

Recently I've had a task in which I need to change visibility of particular button if Item number was serialized.
I found a way how to identify it by checking InventTrans statusReceipt.
But after that my colleague advised to me a way with checking Tracking Dimension Group and now I wanted to share this approach with you, guys!
Maybe it will be useful for someone in future.
Code below:
private boolean checkItemSerialized(ItemId _itemId)
{
    EcoResTrackingDimensionGroupItem        trackingDimensionGroupItem;
    EcoResTrackingDimensionGroup            trackingDimensionGroup;
    boolean ret;
    ;
    trackingDimensionGroupItem  = EcoResTrackingDimensionGroupItem::findByItem(curext(), _itemId);
    trackingDimensionGroup      = EcoResTrackingDimensionGroup::find(trackingDimensionGroupItem.TrackingDimensionGroup);
    if (trackingDimensionGroup.Name == #DimSerial)
    {
        ret = true;
    }
    return ret;
}

вторник, 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 апреля 2015 г.

How to get value divided by symbol AX 2012

Hi everyone.
Today I must create method, which had to create a list from current string value , divided by slash (/).
And I have written this code:

#Characters_CN
    List            list = new List(Types::String);
    ListIterator    iterator;
    container       packCon;
    int             slashCount = 0;

    list = strSplit(this.CoverSheetURL, #slash); //this.CoverSheetURL - your string value       iterator = new ListIterator(list);
    while (iterator.more())
    {
        packCon += iterator.value();
        slashCount++;
        iterator.next();
    }
    return conPeek(packCon, slashCount);


I hope, it will be useful for you :)