Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Run CustAccountStatementExt via X++ with the correct criteria

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Sathish_Chinnappan Profile Picture
    Sathish_Chinnappan 1,307 on at
    Run CustAccountStatementExt via X++ with the correct criteria
    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());

    }

     
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Run CustAccountStatementExt via X++ with the correct criteria

    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.

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Run CustAccountStatementExt via X++ with the correct criteria

    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

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Run CustAccountStatementExt via X++ with the correct criteria

    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();

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,661 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans