Skip to main content

How to insert/remove image in a table

If you need to import an image from your desktop to a table in dynamics AX, then you need a field which extendedDataType is bitmap and here is a code that you can write in the clicked method of your form

void clicked()

{

FilenameFilter filter = ['Image Files','*.bmp;*.jpg;*.gif;*.jpeg'];

BinData binData = new BinData();

str extention, path, nameOfFile;

super();

imageFilePathName = WinAPI::getOpenFileName(element.hWnd(),filter,”, “@SYS53008″, ”,”);

if (imageFilePathname && WinAPI::fileExists(imageFilePathName))

{

[path, nameOfFile, extention] = fileNameSplit(imageFilePathName);

if (extention == ‘.bmp’ ||

extention == ‘.jpg’ ||

extention == ‘.gif’ ||

extention == ‘.jpeg’)

{

binData.loadFile(imageFilePathName);

imageContainer = binData.getData();

element.showLogo();

Thy_InventSymbolsIcons.Image = imageContainer;

}

else

{

throw error(“@SYS89176″);

}

}

element.Query_cntRecords();

}

then if you want to remove an image :

void clicked()

{

super();

element.delete();

}

and the delete mehtod is defined as follows:

void delete()

{;

Thy_InventSymbolsIcons.Image = connull();

Thy_InventSymbolsIcons_ds.refresh();

}

Popular posts from this blog

Dynamics Axapta: Sales Orders & Business Connector

Well, again folllowing my same idea of writting close to nothing and pasting code, I'll paste in some code to create a sales order from some basic data and the invoice it. I'll try to explain more in the future. AxaptaObject axSalesTable = ax.CreateAxaptaObject("AxSalesTable"); AxaptaRecord rcInventDim = ax.CreateAxaptaRecord("InventDim"); AxaptaRecord rcCustTable = ax.CreateAxaptaRecord("CustTable"); rcCustTable.ExecuteStmt("select * from %1 where %1.AccountNum == '" + MySalesOrderObject.CustAccount + "'"); if (MySalesOrderObject.CurrencyCode.Trim().Length == 0) MySalesOrderObject.CurrencyCode = rcCustTable.get_Field("Currency").ToString().Trim(); string sTaxGroup = rcCustTable.get_Field("taxgroup").ToString().Trim(); //set header level fields axSalesTable.Call("parmSalesName", MySalesOrderObject.SalesName.Trim()); axSalesTable.Call("parmCustAccount", M

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() {    MenuFunction mf;    args args = new Args();    ;     args.record(EmplTable);     mf = new menufunction(identifierstr(EmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) {     EmplDuplication EmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }