The OperationContext below was mostly 'ignored' when being called from the Job.
static void ZZZ_SimulateAIFServiceCall(Args _args)
{
// Sales Invoice find() operation
SalesSalesInvoiceService salesInvSvc;
AifQueryCriteria qryCriteria;
AifCriteriaElement criteriaEle;
AifOperationContext opContext;
SalesSalesInvoice salesInvoice;
// Filter to find a customer invoice, in company 'HAL'
criteriaEle = AifCriteriaElement::newCriteriaElement(
"CustInvoiceJour",
"RecId",
AifCriteriaOperator::Equal,
"5637156576");
qryCriteria = AifQueryCriteria::construct();
qryCriteria.addCriteriaElement(criteriaEle);
salesInvSvc = SalesSalesInvoiceService::construct();
// Simulate operation context
opContext = new AifOperationContext(
"XXXX", // ActionId (?)
"SalesSalesInvoice", // AifDocument that we are simulating a call to
14005, // ClassId - classes/SalesSalesInvoice(?)
"find", // Method name
"find", // Op. method name
"AccountsReceivableServices", // AIFPort.name
"HAL", // ***Company / DataAreaId
AifMessageDirection::Inbound, // ***Inbound / Outbound
null); // Map of parameters in Request?
salesInvSvc.setOperationContext(opContext);
// Simulate AIF operation call
salesInvoice = salesInvSvc.find(qryCriteria);
info(strFmt(@'Invoice exists: %1', salesInvoice.existsCustInvoiceJour()));
}
Don't forget to generate the CIL when making changes to the service classes and calling AIF from outside of AX!
No hay comentarios:
Publicar un comentario