Wednesday 26 April 2017

Insert Image For Released Product using X++

static void AddImage(Args _args)
{
 
    DocuActionArchive               docuActionArchive;
    EcoResProductImageManagement    productImageManagement;
    EcoResProductImageThumbnail     ecoResProductImageThumbnail;
    DocuRef                         docuRef;
    DocuValue                       docuValue;
    EcoResProductImage              ecoResProductImage;
    InventTable                     inventTable;
// Specify the display product number

    InventTable = InventTable::find("25231");
    ttsBegin;
    docuRef.TypeId     = "File";
    docuRef.RefTableId = inventTable.TableId;
    docuRef.RefRecId   = InventTable.RecId;
    docuRef.RefCompanyId = inventTable.dataAreaId;
    docuRef.ActualCompanyId = curext();
    docuRef.insert();
    docuActionArchive = DocuAction::newDocuRef(docuRef);
    docuActionArchive.add(docuRef,"C:\\Users\\Sandeep.madupu\\Desktop\\image.jpg");

    ecoResProductImage.RefRecId         = docuRef.RecId;
    ecoResProductImage.RefRecord        = docuRef.RefRecId;
    ecoResProductImage.FileName         = "image.jpg";
    ecoResProductImage.Usage            = EcoResProductImageUsage::External;
    ecoResProductImageThumbnail         = new EcoResProductImageThumbnail(false);
    ecoResProductImage.MediumSize       = ecoResProductImageThumbnail.generateThumbnail(204,204,docuRef);
    ecoResProductImage.ThumbnailSize    = ecoResProductImageThumbnail.generateThumbnail(48,48,docuRef);

    if (ecoResProductImage.MediumSize == connull())
    {
        info("@SYS301935");
    }
    if (ecoResProductImage.ThumbnailSize == connull())
    {
        info("@SYS301936");
    }
    ecoResProductImage.insert();
    ttsCommit;
}


if you are facing below error

"Document management dictionary does not exist",

set the below directories


Organization administration>Setup>document management> Document management parameters, specify the default archive directory..

Organization administration>Setup>document management>document types, select the specific document type and specify the archive directory.


No comments:

Post a Comment