Showing posts with label AIF. Show all posts
Showing posts with label AIF. Show all posts

Tuesday, May 3, 2016

Send via AIF multiple records to outbound file

If you have a requirement to send more than one record per XML as an outbound, then have a look on the following job:
static void AifSendCustomerFromQuery(Args _args)
{
    AxdSendContext                  axdSendContext      = AxdSendContext::construct();
    AifAction                       aifAction;
    AifConstraint                   aifConstraint       = new AifConstraint();
    AifConstraintList               aifConstraintList   = new AifConstraintList();
    AifOutboundProcessingService    aifOutboundProcessingService = new AifOutboundProcessingService();
    AifGatewaySendService           aifGatewaySendService = new AifGatewaySendService();
    AifActionId                     actionId;
    AifEndpointList                 endpointList;
    Query                           query;
    QueryBuildDataSource            queryBuildDataSource;
    ;

    query = new Query(queryStr(AxdCustomer));
    AxdSend::removeChildDs(query);
    queryBuildDataSource = query.dataSourceTable(tablenum(CustTable));
    queryBuildDataSource.addRange(fieldnum(CustTable, RecId));
    queryBuildDataSource.rangeField(fieldnum(CustTable, RecId)).value(strfmt('5637144577..5637144587'));

    aifAction = AifAction::find(AifSendService::getDefaultSendAction(
                                                        classnum(CustCustomerService), 
                                                        AifSendActionType::SendByQuery));

    axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
    axdSendContext.parmSecurity(false);

    aifConstraint.parmType(AifConstraintType::NoConstraint);
    aifConstraintList.addConstraint(aifConstraint) ;

    endPointList = AifSendService::getEligibleEndpoints(aifAction.ActionId,aifConstraintList);

    AifSendService::submitFromQuery(aifAction.ActionId, endpointList, query, AifSendMode::Sync);

    AifGatewaySendService.run();
    AifOutboundProcessingService.run();
}

Tuesday, April 19, 2016

Run AIF import and export manually

Here is a job to run import and export manually, so you don’t have to wait for the batch jobs:
static void AIFImportExport(Args _args)
{
    // Inbound (import)
    new AifGatewayReceiveService().run();
    new AifInboundProcessingService().run();

    // Outbound (export)
    new AifOutboundProcessingService().run();
    new AifGatewaySendService().run();

    info("AIF import/export done");
}