1. Generating the outbound xml file for selected record or single record -
using document service(file system adapter).
2. Generating the outbound xml file for all records( i.e. specified criteria on
the query) - using document service(file system adapter).
Example: Generating the outbound xml file for selected record or single record.
Below is the code to generate the outbound xml file for the selected record.
static void GenerateXmlSelectedRecord(Args _args)
{
AxdSendContext axdSendContext = AxdSendContext::construct();
AifEntityKey aifEntityKey = AifEntityKey::construct();
AifEntityKeyList aifEntityKeyList = AifEntityKeyList::construct();
Map keyData;
AifConstraintList aifConstraintList = new AifConstraintList();
AifConstraint aifConstraint = new AifConstraint();
CustTable custTable;
int i,j;
CustCustomerService CustCustomerService = CustCustomerService::construct();
;
custTable = CustTable::find('Cust001');
keyData = SysDictTable::getKeyData(custTable);
aifEntityKey.parmTableId(custTable.TableId);
aifEntityKey.parmRecId(custTable.RecId);
aifEntityKey.parmKeyDataMap(keyData);
aifEntityKeyList.addEntityKey(aifEntityKey);
axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
axdSendContext.parmSecurity(false);
aifConstraint.parmType(AifConstraintType::NoConstraint) ;
aifConstraintList.addConstraint(aifConstraint) ;
info(strFmt("%1",custTable.AccountNum));
AifSendService::SubmitDefault( classnum(CustCustomerService),
aifEntityKey,
aifConstraintList,
AifSendMode::Async,
axdSendContext.pack());
}
Example: Generating the outbound xml file for all records( i.e. specified criteria on the query).
Below is the code to generate the outbound xml for all the records or specified criteria.
static void GenerateMutiplerecords(Args _args)
{
CustTable custTable;
AxdSendContext axdSendContext = AxdSendContext::construct();
AifEntityKey aifEntityKey = AifEntityKey::construct();
AifConstraintList aifConstraintList = new AifConstraintList();
AifConstraint aifConstraint = new AifConstraint();
AifEndpointList endpointList;
AifActionId actionId;
Query query;
QueryBuildDataSource qbds;
query = new Query(queryStr(AxdCustomer));
AxdSend::removeChildDs(query);
actionId = AifSendService::getDefaultSendAction(classnum(CustCustomerService), AifSendActionType::SendByQuery);
aifConstraint.parmType(AifConstraintType::NoConstraint);
aifConstraintList.addConstraint(aifConstraint) ;
endpointList = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);
AifSendService::SubmitFromQuery(actionId,endpointList,query,AifSendMode::Async);
}
Example: Generating the outbound xml file for selected record or single record.
Below is the code to generate the outbound xml file for the selected record.
static void GenerateXmlSelectedRecord(Args _args)
{
AxdSendContext axdSendContext = AxdSendContext::construct();
AifEntityKey aifEntityKey = AifEntityKey::construct();
AifEntityKeyList aifEntityKeyList = AifEntityKeyList::construct();
Map keyData;
AifConstraintList aifConstraintList = new AifConstraintList();
AifConstraint aifConstraint = new AifConstraint();
CustTable custTable;
int i,j;
CustCustomerService CustCustomerService = CustCustomerService::construct();
;
custTable = CustTable::find('Cust001');
keyData = SysDictTable::getKeyData(custTable);
aifEntityKey.parmTableId(custTable.TableId);
aifEntityKey.parmRecId(custTable.RecId);
aifEntityKey.parmKeyDataMap(keyData);
aifEntityKeyList.addEntityKey(aifEntityKey);
axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
axdSendContext.parmSecurity(false);
aifConstraint.parmType(AifConstraintType::NoConstraint) ;
aifConstraintList.addConstraint(aifConstraint) ;
info(strFmt("%1",custTable.AccountNum));
AifSendService::SubmitDefault( classnum(CustCustomerService),
aifEntityKey,
aifConstraintList,
AifSendMode::Async,
axdSendContext.pack());
}
Example: Generating the outbound xml file for all records( i.e. specified criteria on the query).
Below is the code to generate the outbound xml for all the records or specified criteria.
static void GenerateMutiplerecords(Args _args)
{
CustTable custTable;
AxdSendContext axdSendContext = AxdSendContext::construct();
AifEntityKey aifEntityKey = AifEntityKey::construct();
AifConstraintList aifConstraintList = new AifConstraintList();
AifConstraint aifConstraint = new AifConstraint();
AifEndpointList endpointList;
AifActionId actionId;
Query query;
QueryBuildDataSource qbds;
query = new Query(queryStr(AxdCustomer));
AxdSend::removeChildDs(query);
actionId = AifSendService::getDefaultSendAction(classnum(CustCustomerService), AifSendActionType::SendByQuery);
aifConstraint.parmType(AifConstraintType::NoConstraint);
aifConstraintList.addConstraint(aifConstraint) ;
endpointList = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);
AifSendService::SubmitFromQuery(actionId,endpointList,query,AifSendMode::Async);
}
https://msdn.microsoft.com/en-us/library/aa859008.aspx
http://dynamicsaxarticles.blogspot.com/2011/09/walkthrough-creating-service-using-aif.html
http://blog.bhsolutions.com/index.php/2013/06/resolving-compile-errors-aif-services-dynamics-ax-2012/
http://ajdynamicsax.blogspot.com/2016/10/aif-aifAX2012-is-acronym-for-application.html
http://dynamicsaxarticles.blogspot.com/2011/09/walkthrough-creating-service-using-aif.html
http://blog.bhsolutions.com/index.php/2013/06/resolving-compile-errors-aif-services-dynamics-ax-2012/
http://ajdynamicsax.blogspot.com/2016/10/aif-aifAX2012-is-acronym-for-application.html