Note : The below code allows image only for Released products if you give non released product then it checks whether the given product is released or not and throws error "the given product is not released"
static void
SK_insertimage(Args _args)
{
DocuActionArchive
docuActionArchive;
EcoResProductImageManagement
productImageManagement;
EcoResProductImageThumbnail
ecoResProductImageThumbnail;
DocuRef
docuRef;
DocuValue
docuValue;
EcoResProductImage
ecoResProductImage;
InventTable
inventTable;
EcoResProduct
ecoResProduct;
;
ecoResProduct =
ecoResProduct::findByDisplayProductNumber("A0001");
ecoResProduct = ecoResProduct::findByDisplayProductNumber("A0001");
inventTable = InventTable::find("A0001");
if(inventTable)
{
if(ecoResProduct)
{
ttsBegin;
docuRef.TypeId = "File";
docuRef.RefTableId =
ecoResProduct.TableId;
docuRef.RefRecId =
ecoResProduct.RecId;
docuRef.RefCompanyId =
ecoResProduct.dataAreaId;
docuRef.ActualCompanyId = curext();
docuRef.insert();
docuActionArchive = DocuAction::newDocuRef(docuRef);
docuActionArchive.add(docuRef,"C:\\Users\\shivakumar.p\\Desktop\\download.jpg");
ecoResProductImage.RefRecId
= docuRef.RecId;
ecoResProductImage.RefRecord
= docuRef.RefRecId;
ecoResProductImage.ImageFormat
= "jpg";
ecoResProductImage.FileName
= "download.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;
}
}
else
{
checkFailed("the given product is not released
");
}
No comments:
Post a Comment