lunes, 13 de junio de 2016

Call an AIF service operation via Job

Simulate a call to an AIF service operation via a Job in AX2012.  Thus avoiding having to attach to the server process when debugging.
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(
    qryCriteria = AifQueryCriteria::construct();
    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", //
        "HAL",                        // ***Company / DataAreaId
        AifMessageDirection::Inbound, // ***Inbound / Outbound
        null);                        // Map of parameters in Request?
    // 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