Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Thursday, May 19, 2022

Get current record or select datasource of formDataSource extension of a form in D365

  Hi,

[ExtensionOf(formDataSourceStr(SalesTable, SalesLine))]

final class Dpay_SalesTable_SalesLine_FDS_Extension

{

        //init of SalesLineDS of SalesTable form

void initValue()

{

FormDataSource     formDataSource = this;


SalesLine    salesLine = formDataSource.cursor();

                

                //your logic        


next initValue();


//Your logic

}

}


Regards,


How to select the datasource of a form when you are the extension of formDatasource of another table in D365

 Hi,

[ExtensionOf(formDataSourceStr(SalesTable, SalesLine))]

final class Dpay_SalesTable_SalesLine_FDS_Extension

{

        //init of SalesLineDS of SalesTable form

void initValue()

{

FormDataSource     formDataSource = this;


SalesLine    salesLine = formDataSource.cursor();

SalesTable  salesTable = formDataSource .formRun().dataSource( formDataSourceStr( SalesTable, SalesTable)).cursor();

                

                //your logic        


next initValue();


//Your logic

}

}


Regards,



Sunday, May 15, 2022

renamePrimaryKey() in D365

 Hi,


In this article, we will discuss renamePrimaryKey(). 

In the operation of changing the value any of the primary key values in the system like CustId, VendId, PurchID, PersonnelNumberId, ProjID, etc needs to reflect its supporting relationed child tables.

This can be manually achievable by renaming on record Info of the particular form.

Here my case is to do the same through code for a large list of values.


CustTable CustTable;

ttsBegin;

select firstOnly CustTable where CustTable.AccountNum == "00445";

if (CustTable)

{

CustTable.AccountNum = "CUST-00445";

CustTable.renamePrimaryKey();

}

ttsCommit;

}


On running the above snippet, all the transactions got updated with the new values.

Regards,



Playing with displayOption in D365

Hi,

Change the fonts, colors and other display-related information of the grid or forms can be achieved here.


Override the displayOption() from the formDatasource, if there is multiple db please select the parent DB 


public void displayOption(Common _record, FormRowDisplayOption _options)

{

    HcmWorker   hcmWorkerLoc = _record as HcmWorker;

 

    super(_record, _options);

 

    _options.fontBold(true); // to make the text bold

    _options.fontItalic(true); // to make text Italic

    _options.fontUnderline(true); // to Underline the text by default

    _options.backColor(WinAPI::RGB2int(255,0,127 )); // to change the background color of the glid

    _options.textColor(WinAPI::RGB2int(255,255,0)); // to change the text color of the glid

 

}

 Regards,


How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...