Friday, April 1, 2016

Inserting Image From Folder with X++ Code


static void InsertingimagefromFolder(Args _args)
{
    BinData binData = new BinData();
    ImageStore 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
    }
    if(!fileName)
        {
            checkFailed("please select image ");
        }
    else
    {
        imageFilePathName=filename;
            if ( WinAPI::fileExists(imageFilePathName))
                {
                    binData.loadFile(imageFilePathName);
                    imageContainer = binData.getData();
                    //table.Image = _Party.RecId;
                    table.MediumSize = imageContainer;
                    table.insert();
                }
    }

}

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 ...