Purpose:
The purpose of this document is to illustrate how we can trigger the generation of AIF document service outbound message in X++.
Business requirement:
Ability to generate an AIF outbound xml message on demand.
Assumptions:
Outbound port is configured using file system adapter.
Development:
Please find the job below to trigger an AIF document service outbound message in X++. The job uses the standard CustCustomerService class to generate outbound xml for customer data. Likewise the code can be used for any other valid document service class.
// Developed on 18 Feb 2016 by Muhammad Anas Khan // Blog: dynamicsaxinsight.wordpress.com // LinkedIn: pk.linkedin.com/in/muhammadanaskhan // Description: Trigger AIF document service outbound message static void sendElectronically( XMLDocPurpose _xMLDocPurpose, AifSendMode _aifSendMode = AifSendMode::Async) { AxdSendContext axdSendContext = AxdSendContext::construct(); AifEntityKey aifEntityKey = AifEntityKey::construct(); AifConstraintList aifConstraintList = new AifConstraintList(); AifConstraint aifConstraint = new AifConstraint(); CustTable custTable; Map keyData; custTable = CustTable::find("1101"); keyData = SysDictTable::getKeyData(custTable); aifEntityKey.parmTableId(custTable.TableId); aifEntityKey.parmRecId(custTable.RecId); aifEntityKey.parmKeyDataMap(keyData); axdSendContext.parmXMLDocPurpose(_xMLDocPurpose); axdSendContext.parmSecurity(false); aifConstraint.parmType(AifConstraintType::NoConstraint); aifConstraintList.addConstraint(aifConstraint); AifSendService::submitDefault( classnum(CustCustomerService), //Service class goes here aifEntityKey, aifConstraintList, _aifSendMode, axdSendContext.pack()); }
