Exporting a Report to a PDF and Attaching to a Record in Server-Side Code in Infor CRM (Saleslogix)

I recently had a client that needed to use server-side code to export a report to a PDF and add as an attachment to a record. There’s some tricky code to do this, so I decided to wrap it up in a reusable and open source assembly.

Take a look at the open source FX.ReportUtility repository on Github:

Announcing the FX.ReportUtility Assembly

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 FX.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. There are two public methods, CreateAttachment and SaveAsPDF. Both will take a Crystal RecordSelection Formula.

The RecordSelectionFormula parameter must be a valid Crystal record selection formula. Examples:

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

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

Example #2:

To save the report PDF as an attachment record. The CRMReport class constructor takes the report name. Then, the CreateAttachment you’ll pass, at minimum, a Crystal RecordSelection formula.

// export a report to a PDF and save as an attachment
var report = new FX.ReportUtility.CRMReport("System:My Report");
// 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("{ACCOUNT.ACCOUNTID} = '" + someAccountId + "'");
attachment.AccountId = someAccountId;

Or, to just export the report to a PDF:

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

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.

Get the FX.ReportUtility Assembly

You can grab the entire source code and assembly from Github or download just the compiled assembly below:


Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published.

Subscribe To Our Newsletter

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

You have Successfully Subscribed!