ReportUtility Assembly

The ReportUtility Assembly (DLL) allows you to easily export an Infor CRM report to a PDF from C# code. You can also save report PDFs as attachments to records in Infor CRM.

The ReportUtility Assembly allows you to easily export an Infor CRM report to a PDF from C# code. You can also save report PDFs as attachments to records in Infor CRM.

The FX.ReportUtility provides two public methods. One to export the report to a PDF and another that will export the report to a PDF and add as an attachment record.

Using the ReportUtility Assembly

To use the assembly, first you’ll need to add the DLL to the SupportFiles\Bin folder of the SlxClient portal. Next, you’ll just add the code where needed. The ReportUtility’s CRMReport class has two public methods, CreateAttachment (which exports the report to a PDF and attaches it to a record) and SaveAsPDF (which simply exports the report to a PDF file).

Once you create a CRMReport object (FX.ReportUtility.CRMReport), you’ll need to set a RecordSelectionFormula to filter the report for some specific record or records. The RecordSelectionFormula must be a valid Crystal record selection formula.

Attaching a Report as a PDF to a Record

// export a report to a PDF and save as an attachment
var report = new FX.ReportUtility.CRMReport("System:My Report");

// set a filter for the report to use a specific record in the report
report.RecordSelectionFormula = "{ACCOUNT.ACCOUNTID} = '" + someAccountId + "'";
// call CreateAttachment which returns an Attachment record, 
// which you'll need to set the references for the record it 
// is for and then save it
var attachment = report.CreateAttachment();
attachment.AccountId = someAccountId;
attachment.Save();

Exporting a Report as a PDF File

// export a report as a PDF 
var report = new FX.ReportUtility.CRMReport("System:My Report");
report.RecordSelectionFormula = "{ACCOUNT.ACCOUNTID} = '" + someAccountId + "'";
var exportedFile = report.SaveAsPDF();

The methods do have other options such as a specific path to save the report as, and name of the file, as well as adding a description to the attachment record.

Setting Report Prompts/Parameters

You can also set report “prompts” (parameters) as well.

// export a report as a PDF 
var report = new FX.ReportUtility.CRMReport("System:My Report");
// set report parameters 
report.SetParameter("AccountID", someAccountId);
report.SetParameter("ActivityDate", someDateValue);
// you can also set the record selection formula in conjunction with parameters
report.RecordSelectionFormula = "{ACTIVITY:USERID}= '" + someUserId + "'";
var exportedFile = report.SaveAsPDF();

Setting Crystal Record Selection Formulas

To filter the report for a specific record or records, you need to set a valid Crystal record selection formula in the RecordSelectionFormula property. Some examples include:

Example #1:
“{OPPORTUNITY.OPPORTUNITYID} = ‘” + someOpportunityId + “‘”

It can also be more complex, such as the following:

Example #2:
“{OPPORTUNITYQUOTE.OPPORTUNITYQUOTEID} = ‘” + someOpportunityQuoteId + “‘ AND {OPPORTUNITY_CONTACT.ISPRIMARY} = ‘T’ AND NOT ({PRODUCT.NAME} = ‘Custom Door Panel’ OR {PRODUCT.NAME} = ‘Custom Drawer Panel’)”

For more information on valid Crystal record selection formulas, refer to the Crystal Reports documentation.

Download ReportUtility Assembly

Download

Note: Source is also available on Github, visit the repository here.

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!