Search This Blog

Saturday, October 22, 2011

Call AIF OutBound Service using X++

This job is used to read the sales order based on Sales id and loads into the outboundchannel location.

static void krish_OutboundAifProcess(Args _args)
    {
        AxdSendContext          axdSendContext      = AxdSendContext::construct();
        AifEntityKey            aifEntityKey        = AifEntityKey::construct();
        AIFQueryCriteria   QueryCriteria;
        AifAction               aifAction ;
        AifConstraint           aifConstraint       = new AifConstraint();
        AifConstraintList       aifConstraintList   = new AifConstraintList();
        SalesTable  salesTable;
        AifOutboundProcessingService AifOutboundProcessingService = new AifOutboundProcessingService();
        AifGatewaySendService   AifGatewaySendService = new AifGatewaySendService();
        ;
        aifAction = AifAction::find(AifSendService::getDefaultSendAction(classnum(AIFCRMOrderReturnService),AifSendActionType::SendByKey)) ;
        salesTable = SalesTable::find("10334");
        aifEntityKey.parmTableId(salesTable.TableId);
        aifEntityKey.parmRecId(salesTable.RecId);
        aifEntityKey.parmKeyDataMap(SysDictTable::getKeyData(salesTable));
        axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
        axdSendContext.parmSecurity(false);
        aifConstraint.parmType(AifConstraintType::NoConstraint);
        aifConstraintList.addConstraint(aifConstraint) ;
        AifSendService::submitDefault(classnum(AIFCRMOrderReturnService),
                                        aifEntityKey,
                                        aifConstraintList,
                                        AifSendMode::Sync,
                                        axdSendContext.pack());
        AifOutboundProcessingService.run();
        AifGatewaySendService.run();
    }

4 comments:

  1. Hi
    When I try to use CustCustomer AIF service in Excel Add-in its giving the following error.

    The relation between datasource CustTable and data source Dirparty contains an unsupported RecId Relationship.

    Plz help me on this

    ReplyDelete
    Replies
    1. Hi Ashish,
      Excel Add-in have its own limitations, when the relation type was recid relation without replacementkey it doesnt support.there was the round way to do if you want to do you have to create another int64 field in that table and you have to create the index and you have to define that index alternatekey yes and assign that index to replacementkey and you can try...but changing the standard table may affect the other functionalities...

      So we created the logic to import from x++...for these type of scenarios....mostly....

      Regards,
      krishna.

      Delete
  2. Hi Krish,

    There is a replacement key already existing in Dirparty Table, with index name PartyNumIdx. I have created a field of int64 type and added the new field and RecId to the PartyNumIdx. when I try to access the service now its throwing the error
    "An Item with same key has already been Added"
    need help
    Thanks

    ReplyDelete
    Replies
    1. Hi Ashish,
      I think there is some problem in defining some replacementkeys...please use this link for reference

      http://ax2012exceldataimport.blogspot.dk/2012/01/dynamics-ax-2012-customers-import-using.html

      Regards,
      krishna.

      Delete

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

Thanks,
krishna.