Month: February 2016

AX 2012: Trigger AIF Document Service Outbound Message in X++

Posted on Updated on

Purpose:

The purpose of this document is to illustrate how we can trigger the generation of AIF document service outbound message in X++.

Business requirement:

Ability to generate an AIF outbound xml message on demand.

Assumptions:

Outbound port is configured using file system adapter.

Development:

Please find the job below to trigger an AIF document service outbound message in X++. The job uses the standard CustCustomerService class to generate outbound xml for customer data. Likewise the code can be used for any other valid document service class.

// Developed on 18 Feb 2016 by Muhammad Anas Khan
// Blog: dynamicsaxinsight.wordpress.com
// LinkedIn: pk.linkedin.com/in/muhammadanaskhan
// Description: Trigger AIF document service outbound message
static void sendElectronically(
    XMLDocPurpose _xMLDocPurpose,
    AifSendMode   _aifSendMode = AifSendMode::Async)
{
    AxdSendContext    axdSendContext = AxdSendContext::construct();
    AifEntityKey      aifEntityKey = AifEntityKey::construct();
    AifConstraintList aifConstraintList = new AifConstraintList();
    AifConstraint     aifConstraint = new AifConstraint();
    CustTable         custTable;
    Map               keyData;
    
    custTable = CustTable::find("1101");
    
    keyData = SysDictTable::getKeyData(custTable);
    aifEntityKey.parmTableId(custTable.TableId);
    aifEntityKey.parmRecId(custTable.RecId);
    aifEntityKey.parmKeyDataMap(keyData);
    axdSendContext.parmXMLDocPurpose(_xMLDocPurpose);
    axdSendContext.parmSecurity(false);
    aifConstraint.parmType(AifConstraintType::NoConstraint);
    
    aifConstraintList.addConstraint(aifConstraint);
    AifSendService::submitDefault(
        classnum(CustCustomerService),  //Service class goes here
        aifEntityKey,
        aifConstraintList,
        _aifSendMode,
        axdSendContext.pack());
}

AX 2012: Print SSRS Report in PDF to Disk

Posted on Updated on

Purpose:

The purpose of this document is to illustrate how we can print an SSRS report in PDF format to disk or file-system in X++.

Business requirement:

Ability to print an SSRS report in PDF format to disk or file-system automatically.

Assumptions:

SSRS report is successfully deployed to the report server.

Development:

Please find below the job to write SSRS report in PDF to disk or file-system.

// Developed on 01 Feb 2016 by Muhammad Anas Khan
// Blog: dynamicsaxinsight.wordpress.com
// LinkedIn: pk.linkedin.com/in/muhammadanaskhan
// Description: Write SSRS report in PDF to disk
static void makPrintSSRSReportToDisk(Args _args)
{
    //Instantiate custom controller
    SRSPrintDestinationSettings printSettings;
    SrsReportRunController 	controller = new PurchPurchaseOrderController();
        
    controller.parmReportName(ssrsReportStr(PurchPurchaseOrder, Report));

    //Get print settings from contract
    printSettings = controller.parmReportContract().parmPrintSettings();

    // set print medium
    printSettings.printMediumType(SRSPrintMediumType::File);
    printSettings.fileFormat(SRSReportFileFormat::PDF);
    printSettings.overwriteFile(true);
    printSettings.fileName(@"C:\Temp\PurchPurchaseOrder.pdf");

    // suppress the parameter dialog
    controller.parmShowDialog(false);
    controller.startOperation();
}