This following sample code used to get the Template based on the paremeter that was defined and apply that template for the released product.
//this methods is used to retrieve the Templata data based on the Parameter and returns the container of the templateData that will be used in apply template functionality.
private container getTemplateData()
{
SysRecordTemplateTable templateTable;
SysRecordTmpTemplate tmp;
container dataContainer,RecordTmplateData;
ParameterLocationTable parameterLocation;
int i;
;
parameterLocation = ParameterLocationTable ::find("TestLocation");
sysRecordTmpTemplate=null;
if( parameterLocation )
{
select templateTable where templateTable.table==tableNum(inventTable);
dataContainer=templateTable.Data;
for (i=conlen(dataContainer); i; i--)
{
[tmp.Description, tmp.DefaultRecord, tmp.Data, tmp.Details] = conpeek(dataContainer, i);
if(tmp.Description== parameterLocation .ItemTemplate)
{
tmp.OrgDescription=tmp.Description;
tmp.insert();
RecordTmplateData=tmp.data;
}
}
}
return RecordTmplateData;
}
// apply the Template for the released Product to the company
private void applyTemplate()
{
EcoResProductTemplateApplyManagerUtils utils;
InventTable inventTable;
container recordTmpValues;
// if Product is released to the company
if (releaseProductToCompany)
{
inventTable = InventTable::Find("Item1");
recordTmpValues=this.getTemplateData(_changeOrderProduct);
utils = EcoResProductTemplateApplyManagerUtils::newDefault();
utils.applyTemplate(
recordTmpValues,
inventTable.ItemId);
}
}
Hi Krishna,
ReplyDeleteCan you please let me know whre i have to find ParameterLocationTable that you specified in your code.
I tried but unable to locate it in the AOT.
Thanks
Dinesh
Hi Dinesh,
DeleteThat was the my custom table where I defined which template i have to use to apply for product, so you can create your owntable where you have to define the template name to use to apply.
Regards,
krishna.
Hi Krishna,
ReplyDeleteHow to apply template at the time of product creation..?
Does your code apply template after the product is created...?