Skip to main content

Save SSRS report in PDF and send email attachemnt x++

public void SaveSSRStoPDF()
{
    SrsReportRunController              ssrsController = new SrsReportRunController();
    PayslipContract                 Contract = new PayslipContract();
    SRSPrintDestinationSettings         printerSettings;
    Filename                            ReportPath;
 
    while select HcmWorker
    {
         
            ReportPath = "C:\\"+ int2str(yearName) +"\\"+ int2str(monthName) +"\\"+ HcmWorker.PersonnelNumber +".pdf";
            ssrsController.parmReportName(ssrsReportStr(WorkerPayslip, Report));
            ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
            ssrsController.parmShowDialog(false);
            Contract.parmPayGrpCode(PayGrpCode);
            Contract.parmYearName(yearName);
            Contract.parmHcmPersonnelNumberId(HcmWorker.PersonnelNumber);
            Contract.parmMonthName(monthName);
            ssrsController.parmReportContract().parmRdpContract(Contract);

            //link the printer settings to the controller
            printerSettings = ssrsController.parmReportContract().parmPrintSettings();
            //print to pdf and always overwrite if the file exists
            printerSettings.printMediumType(SRSPrintMediumType::File);
            printerSettings.fileFormat(SRSReportFileFormat::PDF);
            printerSettings.overwriteFile(true);
            printerSettings.fileName(ReportPath);


            //run & save the report
            ssrsController.runReport();
         // code to send email to employee with attached salary slip
            this.email(ReportPath);
            }
    }
}
For Email click here

Comments

Popular posts from this blog

How to change client Language in ax 2012

Hello,  As you know that Dynmics Ax run on different languages. So I gonna tell you how to change client language country/region specific. this is nothing but a very simple step to do. Go To > File > Tools > Options > After that go to General tab and select the language which you want to use in your client. then apply and exit. In my case I was using Arabic language. Now restart your client and see the difference. You can do it from your database also . Go to Database server  . In my case it is sql server 2014. Select your database > tables > UserInfo > select the user > change the language code. Done Thanks.

Simple x++ query with enum value range

static void queryEnumValue(Args _args) {     Query                   query;     QueryRun                queryrun;     QueryBuildDataSource    qbds;     QueryBuildRange         qbr;     PurchTable              purchTable;     ;         query = new Query();         qbds = query.addDataSource(tableNum(PurchTable));     qbds.addSortField(fieldNum(PurchTable, PurchId), SortOrder::Ascending);     qbr     = qbds.addRange(fieldNum(PurchTable, PurchStatus));         qbr.value(enum2str(PurchStatus::Received));         queryrun = new QueryRun(query);         while(queryrun.next())     {         purchTable = query...

Post product receipt for registered quantity x++, Ax 2012

public void Run() {     PurchFormLetter             purchFormLetter;     PurchFormletterParmData     purchFormLetterParmData;     PurchParmUpdate             purchParmUpdate;     PurchParmTable              purchParmTable;     PurchParmLine               purchParmLine;     PurchTable                  purchTable,purchTable1;     PurchLine                   purchLine;     InventTrans                 inventTrans;     InventTransOrigin           inventTransOrigin;     PurchId                     purchId;     Num     ...