To open SSRS report from code/X++ code to open SSRS Report

Below code opens the Dialog box where we can can specify the Parameters:

static void OpenSSRSFromCode(Args _args)
{
SrsReportRunController controller = new SrsReportRunController();

// establish the report name
controller.parmReportName(ssrsReportStr(ReportName,DesignName));

// suppress the parameter dialog
controller.parmShowDialog(true);

// start the operation
controller.startOperation();
}

____________________________________________

SSRS saving in PDF & Passing the Parameters through X++:

static void SSRSReporttoPDF(Args _args)
{

SrsReportRun srsReportRun;

srsReportRun = new SrsReportRun("ReportName.DesignName");

srsReportRun.init();
srsReportRun.reportCaption("ReportName.DesignName");

//Passing the Parameters through X++
//srsReportRun.reportParameter("ParameterName").value("ParameterValue");

srsReportRun.showDialog(false);

// Print to a file named ReportExample in HTML/PDF format.
srsReportRun.printDestinationSettings().printMediumType(SRSPrintMediumType::File);
srsReportRun.printDestinationSettings().fileFormat(SRSReportFileFormat::PDF);
srsReportRun.printDestinationSettings().overwriteFile(true);
srsReportRun.printDestinationSettings().fileName(@"C:\ReportName.pdf");

if( srsReportRun )
{
srsReportRun.executeReport();
}
} 

OR

SSRS saving in PDF

static void SSRSReporttoPDF(Args _args)
{

SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings printSettings;

// set report name
controller.parmReportName(ssrsReportStr(ReportName,DesignName));

// 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:\Report.pdf");

// suppress the parameter dialog
controller.parmShowDialog(true);

// start operation
controller.startOperation();
}

_____________________________________

Job to Open/Access Menu Item:

static void JobToOpenMI(Args _args)
{
MenuFunction menuFunction;
;
menuFunction = new MenuFunction(menuitemDisplayStr(CustVendReport), MenuItemType::Display);
menuFunction.create();
menuFunction.run();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s