Wednesday, March 30, 2016

How to Insert Image in Ax table Using X++ in Ax 2012

How to Insert Image in Ax table Using X++ in Ax 2012


http://aspcodder.blogspot.in/2016/03/how-to-insert-image-in-ax-table-using-x.html
In this Example we will see How to Insert Image in Ax table and Retrieve from Sql. First Create table in Ax and Create Jo for insert image in table.

Create table from AOT Node.
Step 1: Create Table Name it “A_ImageTable”. And Insert Container Filed in Table.

  • Expand AOT Node.
  • Open Data Dictionary Node.
  • Select Tables and right Click Select New Table.
  • Name it “A_ ImageTable”.
  • Now open table in Insert Some Data in A_ ImageTable table.

Create Job from AOT


  • In the AOT, click Job.
  • Right-click the Job node, and then select New Job.

static void ImageField(Args _args)
{
    BinData binData = new BinData();
    A_ImageTable table;
    dialog               d;
    Dialog                      dialog = new dialog();
    dialogField                 dialogFilename;
    //COM wordDocuments;
    FileName                    fileName;
    container imageContainer;
    str imageFilePathName;
    d = new dialog();
    d.caption("select a Image file");
    dialogFilename = d.addField(extendedTypeStr(FilenameOpen),"File Name");//add a field where you select your file in a specific path
    d.run();//execute dialog
    if(d.closedOk())
    {
        filename = dialogFileName.value();//return path file value
    }
    imageFilePathName=filename;
    if ( WinAPI::fileExists(imageFilePathName))
    {
        binData.loadFile(imageFilePathName);
        imageContainer = binData.getData();
        //table.Image = _Party.RecId;
        table.Image = imageContainer;
        table.insert();
    }
}

Now run your Created Job and Select Image File for FileDialogBox and Click OK and See Output in your table.

No comments:

Post a Comment

Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...