Hi,
I'm implementing a product management in Ax2012 through AIF services. I'm able to create and release products successfully. However, I also need to be able to apply a product template to a released product from the code. I have implemented the template related logic in the server side using x++. The logic is based on the below examples I found ( http://krishhdax.blogspot.fi/2012/06/ax2012-apply-template-for-product-using.html and https://community.dynamics.com/ax/f/33/p/43584/79151.aspx ). In the first example the template is applied to an InventTable using EcoResProductTemplateApplyManagerUtils. However the problem I'm facing right now is that if I try to create an instance of the manager by calling theEcoResProductTemplateApplyManagerUtils::newDefault() the call fails and I get an error: "Exception of type 'Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException' was thrown.". The creation fails even if it's the only line of code I try to execute. Is this some known issue and is there a way to get around this somehow, or is there some other - perhaps completely different - way of applying a template to a released product?
Below is the code I have so far:
public void ApplyTemplate( System.String _productnumber, System.String _templatename )
{
InventTable inventTable;
container recordTmpValues;
EcoResProductTemplateApplyManagerUtils utils;
inventTable = InventTable::Find( _productnumber );
recordTmpValues = this.getTemplateData( _templatename );
utils = EcoResProductTemplateApplyManagerUtils::newDefault(); // --> this call fails!
utils.applyTemplate( recordTmpValues, inventTable.ItemId );
}
// private method for retrieving the template data container
private container getTemplateData(System.String _templatename)
{
SysRecordTemplateTable templateTable;
SysRecordTmpTemplate tmp;
SysRecordTemplateData tmpdata;
container dataContainer,RecordTmplateData;
int i;
boolean DefaultRecord;
templateTable = SysRecordTemplateTable::find( 175 ); // pass invent table id
dataContainer = templateTable.Data;
for(i=2; i<conlen(dataContainer); i++) // 1st element of template data is version, so start from 2
{
[tmp.Description, DefaultRecord, tmp.Data, tmp.Details] = conpeek(dataContainer, i);
if(tmp.Description == _templatename )
{
tmp.OrgDescription=tmp.Description;
tmp.insert();
RecordTmplateData=tmp.data;
}
}
return RecordTmplateData;
}
Any help is appreciated, thanks a lot!
Kind regards,
Kaj Gustafsson
*This post is locked for comments
I have the same question (1)