web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Run CustAccountStatementExt via X++ with the correct criteria

(0) ShareShare
ReportReport
Posted on by

Hey Guys,


I have an AIF web service which is going to be how we are generating and delivering our External Customer Account Statments (CustAccountStatementExt).  I have a class called RMPDocuGet() which handles Invoices and Statements.

My question is how can I generate the CustAccountStatementExt via X++ code using the correct criteria?  Currently it works fine and i can generate statements via the web service for any one of the customers but it's EVERYTHING.  I'd like to set the following up

To Date = 09/23/2015

Only Open = True

Balance other than zero = true

Show Credit Limit = true

Here is the code I'm using to generate the statement now:

public static void RMPPrintStatement(Common _record, Filename filename)
{
    args args = new args();
    CustTable                   custTable = _record;
    SRSPrintDestinationSettings printSettings;
    CustAccountStatementExtController controller = new CustAccountStatementExtController();
    str                         pdfPath = filename;
    int                         pausePrint;

    args.record(_record);
    
    // Name the Report    
    controller.parmReportName( ssrsReportStr( CustAccountStatementExt, 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(pdfPath);
    controller.RMPparmLockDestinationProperties(true);


    // Suppress the parameter dialog
    controller.parmShowDialog(false);
    controller.parmArgs(args);


    // Start operation
    controller.startOperation();

}

Any help would be appreciated.

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,666 Super User 2026 Season 1 on at

    i don't have time to be very specific to your case, in terms of reading or executing your code, but I can present you a general idea. here you go. If you need any explanation on following example, you can have question, further. Example should be pretty self-explanatory 

    TemporarayTable1                objectOfTemporarayTable1;
        TemporarayTable2                objectOfTemporarayTable2;
    
        ContractClassName               contractCls;
        RDPClassName                    rdpCls;
        ;
        rdpCls          =   new RDPClassName();
        contractCls     =   new ContractClassName();
    
        contractCls.parameter1("AnyValue");
        contractCls.parameter2(AnyValue);
    
        rdpCls.parmDataContract(contractCls);
    
        rdpCls.processReport();
        
        objectOfTemporarayTable1    = rdpCls.getTempTable1MethodName();
        objectOfTemporarayTable2     = rdpCls.getTempTable2MethodName();
  • Sohaib Cheema Profile Picture
    49,666 Super User 2026 Season 1 on at

    in your case your method/code is not returning you anything, so I am not sure how you are returning back the data via AIF

    in example which I have given you, as you can see I am getting values/data for two temporary tables, where I will get data. I can return those tables via AIF

  • Community Member Profile Picture
    on at

    The code you gave in your first response makes total sense, working on that now.  I don't it's actually going to return to me the save location (i'm using create!forms from bottom line to output the pdf).  

    I'm working on trying to pass the contract to the controller.

    thanks for the help thus far Sohaib.

  • Sathish_Chinnappan Profile Picture
    1,318 on at
    I can send email with customer statement pdf with no customer statement content. However, the content does exist by manually with the same parameters. Below is my code:

    controller.parmReportName(reportName);

    fileName = strFmt("SOA_%1.pdf",custTable.AccountNum);

    contract = controller.parmReportContract().parmRdpContract();

    contract.parmRecordId(custTable.RecId);  // Record id must be passed otherwise the report will be empty



    contract.parmFromDate(mkdate(1,1, 2000));

    contract.parmToDate(today());

    contract.parmOnlyOpen(true);

    contract.parmIncludeReversed(false);

    contract.parmPrintNonZero(true);

    contract.parmPrintPaymentSchedule(false);

    contract.parmPrintCreditLimit(true);

    contract.parmPrintAging(false);

    contract.parmAgingPeriod(false);

    contract.parmAgingBucketPrintDescription(false);





    contract.parmDayMonth(DayMonth::Day);

    contract.parmManualSetup(false);

    contract.parmPrintAmountGiro(false);

    contract.parmPrintGiro(PaymentStub::None);

    contract.parmPrintingDirection(ForwardBackwardPrinting::Forward);

    contract.parmPrintType("");

    contract.parmSpecifyDueToDate(dateNull());*/



    //contract.parmCustAccount(custTable.AccountNum);

    contract.parmCustAccountStatementExtTmp(custAccountStatementExtTmp.getPhysicalTableName());



    Query query;

    MapEnumerator enumerator;



    enumerator = controller.parmReportContract().parmQueryContracts().getEnumerator();

    enumerator.moveNext();

    query = enumerator.currentValue();

    query.dataSourceTable(tableNum(CustTable)).addRange(fieldNum(CustTable, AccountNum)).value(queryValue(custTable.AccountNum));



    srsReportRun = controller.parmReportRun() as SrsReportRunImpl;

    controller.parmReportRun(srsReportRun);

    controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);    // remove

    controller.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);

    controller.parmReportContract().parmPrintSettings().fileName(fileName);

    controller.parmShowDialog(true);

    controller.parmReportContract().parmPrintSettings().overwriteFile(true);

    //controller.run();



    //SRSReportExecutionInfo executionInfo = new SRSReportExecutionInfo();

    controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());

    controller.parmReportContract().parmReportExecutionInfo(executionInfo);





    srsReportRunService.getReportDataContract(controller.parmreportcontract().parmReportName());



    srsReportRunService.getReportDataContract(controller.parmreportcontract().parmReportName());

    srsReportRunService.preRunReport(controller.parmreportcontract());

    reportParametersMap = srsReportRunService.createParamMapFromContract(controller.parmReportContract());

    parameterValueArray = SrsReportRunUtil::getParameterValueArray(reportParametersMap);



    settings = controller.parmReportContract().parmPrintSettings();

    settings.printMediumType(SRSPrintMediumType::File);

    settings.fileName(fileName);

    //settings.parmEMailContract(emailContract);

    settings.fileFormat(SRSReportFileFormat::PDF);



    srsProxy = SRSProxy::constructWithConfiguration(controller.parmReportContract().parmReportServerConfig());

    //Actual rendering to byte array

    reportBytes = srsproxy.renderReportToByteArray(controller.parmreportcontract().parmreportpath(),

    parameterValueArray,

    controller.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF),

    settings.deviceinfo());





    // You can also convert the report Bytes into an xpp BinData object if needed

    container binData;

    Binary binaryData;

    System.IO.MemoryStream mstream = new System.IO.MemoryStream(reportBytes);

    binaryData = Binary::constructFromMemoryStream(mstream);

    if(binaryData)

    {

    binData = binaryData.getContainer();

    }



    // Turn the Bytes into a stream

    for(int i = 0; i < conLen(binData); i++)

    {

    binData1 = conPeek(binData,i+1);

    stream1 = new System.IO.MemoryStream(binData1);

    }



    email = '';

    if(custTable.email() != '')

    {

    email = custTable.email();

    }

    else

    {

    email = CustParameters::find().CustomerSOACC;

    }



    if(email)

    {

    var messageBuilder = new SysMailerMessageBuilder();

    messageBuilder.setPriority(System.Net.Mail.MailPriority::High);

    messageBuilder.addTo(custTable.email())

    .addCc(CustParameters::find().CustomerSOACC)

    .setSubject(strFmt("%1
    - %2",
    SysEmailMessageTable::find(CustParameters::find().CustomerSOAEmailITemp,"en-us").Subject,
    custTable.name()))


    .setBody(SysEmailMessageTable::find(sysEmailTable.EmailId,'en-us').Mail)

    .setFrom(sysEmailTable.SenderAddr ,sysEmailTable.SenderName);



    if (stream1 != null)

    {

    messageBuilder.addAttachment(stream1,fileName);

    }



    SysMailerFactory::getNonInteractiveMailer().sendNonInteractive(messageBuilder.getMessage());

    }

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans