Skip to main content

Posts

Showing posts with the label image

Store and retrieve an image in a table for a record in AX

The simplest way to store an image for a record into AX tables is by using the CompanyImage Menu Item. I will explain you with an example below: Generally, most of the customers would request for a functionality to store an image for an item. For this, there is no need of high customization. Initially, Goto the Design in InventTable Form and add a Display Menu Item called CompanyLogo to its button Group. Change the label of the Menu item button in the form. Now, open the InventTable form and click on the menu item and load an image associated with a record. This image will be stored in the CompanyImage table as a BLOB in a container with the refRecId, RefTableId and RefCompanyId of the associated record(Here Record of InventTable). Retrieving it and saving to file system again is pretty easy with the help of binData Class. Here is the supporting code snippet.... bindata   bin = new bindata(); str    content; container image; InventTable inventT...

How to display image in each line of a grid

Create ImageList in form.init(): imageList = new ImageList(ImageList::smallIconWidth(), ImageList::smallIconHeight(); Image image = new Image(); ; image.loadImage(filename) imageList.add(image); // … image.loadImage(filename-n) imageList.add(image); ImageList must be declared in ClassDEclaration section. Set AutoDaclaration property of Window field in the Grid to “Yes”. Set ImageList for the window field in the method init() of form: MyWindow.imageList(imageList); On the Table which you are using on the form create the display method. Something like this: display int status() { if(this.amount > 10) return 5; // 5th image from image list else return 6; } Set properties DataSource and DataMethod for your window control: DataSource = DataMethod = status

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(); } an...

image exists in the correct directory

The code checking that the image exists in the correct directory has a BUG and well it is overly complex (KISS).  Just replace this method below... public static boolean isFromAttachmentsFolder(str _pathName) { str attachmentsFolder; str pathName; ; // Fix embedding images in emails attachmentsFolder = SysEmailParameters::find().AttachmentsPath; pathName = _pathName; attachmentsFolder = Global::strReplace(attachmentsFolder,'\\','/'); pathName = Global::strReplace(pathName,'\\','/'); // Fix embedding images in emails return Global::strStartsWith(strupr(pathName), strupr(attachmentsFolder)); }