Outbound and Inbound file generation using File system adapter in AX 2012
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);
}
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);
}
No comments:
Post a Comment