Search This Blog

Tuesday, November 1, 2011

Call File Outbound AIF Service using Query in X++

The following code is used to execute the AIF File outbound  Service using Query  for AIF find Operation.
ex:= Sales Table-salesid,another field and call AIF find to execute query criteria.

static void krish_OutboundAifQueryProcess(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(AIFCRMOrderReturn));

        queryBuildDataSource = query.dataSourceTable(tablenum(EDSACRMSyncLog));
        queryBuildDataSource.addRange(fieldnum(EDSACRMSyncLog,CRMOrderId)).
                                                                                    value(QueryValue('2500591'));
        queryBuildDataSource.addRange(fieldnum(EDSACRMSyncLog,DocReturn)).
                                                                             value(QueryValue(NoYes::No));

       aifAction = AifAction::find(AifSendService::getDefaultSendAction(classnum
               (EDSACRMOrderReturnService),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();
    }

No comments:

Post a Comment

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.