SSRS - Feeding report style number/description into RDL

I’m trying to consolidate several different RDL’s which we currently have in use for similar Invoice report styles. We have separate customs invoice forms for our 3 different companies, and a jointly used regular invoice.

In the interest of easier maintenance and improvements, I want to combine all of the RDL’s into one, while keeping the different report styles available. Then use hide expressions on parts that are customs specific. I figured one way to do this is to somehow feed the selected style number or description in as a usable field. I just can’t figure out how to do that, or if it’s even possible.

Anyone able to give any thoughts, or whether this has been covered before? I haven’t found anything too helpful from searching

I have done this with BAQ reports where you use a calculated field to determine the hidden features. In your case the calculated field would equal 1, 2, or 3 to determine what is hidden. You are using a built-in report?

It’s a modified copy of the ARForm report

Are you using a custom RDD?

Something like this might work if that is the case…

CASE
WHEN [Table.Company] = ‘Company01’ THEN 1
WHEN [Table.Company] = ‘Company02’ THEN 2
WHEN [Table.Company] = ‘Company03’ THEN 3
ELSE 0
END

Add this as a report calculated field on whatever table houses company.

Yes, using a custom RDD. Thanks for the suggestion, that’s how we are currently getting around anything that’s company specific, however the issue is anything that needs to be shown/hidden between regular and customs invoices. In this case, if I want to use the same form with different report styles, the only difference (I believe) would be the style number or description

Hmmm, I suppose I’m not following. As long as that calculated field comes through on the report, you should be able to use that field for a show/hide expression in SSRS. Can you give me more information on your exact use case? In my head I’m thinking there is one RDD, one Report Style, and you are trying to hide objects on that report style based on the company. Is that right?

I believe if you want 3 report styles then you must publish rdl to each. If you make everything dynamic you can probably publish the same rdl but you’ll still need to publish thrice.

Another way would be publish once then duplicate twice.

It sounds like you want to make one .rdl that is “Report Style Aware” and could have multiple report styles pointing to the same RDL path/file (which would allow you to modify/upload it only one time, but your change be immediately applicable to each report style without having to upload it to each one)

That sounds neat. Let’s make it work.

First, conceptually, in cloud, SSRS is hosted on a separate VM instance from our app server, in a one-to-many customer-to-SSRS-server setup. Our Custom Report Styles are segregated by SiteID to keep yours and mine separate, if we are hosted on the same SSRS instance.

This means that report style A can see the same folder structure as report style B and report style C, which makes your concept possible.

I’m using JobTrav as an example, this would apply to any report style.

Since Report Style (ReportStyleNum) isn’t available to SSRS anywhere, let’s find out where it is available, and make it available to SSRS.

First, a quick trace, what BO fires when we submit a SysTask to generate a report? In the case of JobTrav, it’s Erp.Rpt.JobTravSvc/SubmitToAgent.

Knowing the right BO to target, let’s go into BPM Designer on that BO, and set up a Pre-Processing Directive with custom C# code. Open the code designer.

At the right side of the custom code designer, we can see the objects available to us under the Data tab.

Looking to the Kinetic F12 Dev Tools trace when we submit a report, we can see the dataset that is sent to SubmitToAgent. ds\ReportStlye contains all Report Styles for this Report ID. ds\JobTravParam contains the parameters used to generate this report, and the one of particular note at the moment is “ReportStyleNum”

The first object of note under Data tab is “Parameters” → “ds” → “JobTravParam” → “ReportStyleNum”

The second object of note under Data tab is “Call Context” →

There we can see two DataTables available to us, “callContextBpmData” and “callContextClient” - the latter already gets populated by Epicor, and we don’t want to override it for this task. Let’s use the former.

Paste this into the Custom Code:

callContextBpmData.Number01 = ds.JobTravParam[0].ReportStyleNum;

This will pull the first row of JobTravParam (we can see in our F12 Dev Tools trace that only one row is sent) - and set callContextBpmData.Number01 equal to the ReportStyleNum (1002)

Now, with this BPM Saved and enabled, the data is available to us within SSRS.

We can utilize this same method to make any other data we like available within SSRS through the Pre BPM, like user email who printed the report, for example. (I know that’s a popular ask and only available as a calculated field on some RDDs!)

Now, make a copy of the base style, in my example my copy is 1002.

Download the copied report style locally, which gives a path something like reports/CustomReports/JobTraveler/Traveler

Set the report location to a custom folder that doesn’t exist yet. In my case i used reports/CustomReports/JobTravelerMod/Traveler

Change the local path of your downloaded folder structure to match this (Rename the JobTraveler folder to JobTravelerMod)

Open up Traveler.rdl
Add a new dataset. Name it CallContextBpmData, set the Data Source to the existing source of dsTraveler.

Hit fx to create a query
Use this for your query:

="SELECT * FROM CallContextBpmData_" + Parameters!TableGuid.Value + " T1"

That will pull the “CallContextBpmData” object that we modified earlier to set Number01 to our Report Style from the BPM. (we pull all fields because we are lazy, and who knows when we might want to add more to expand the usage)

Now, save the query (hit ok), then go to “Fields” section of the “CallContextBpmData” Dataset Properties, and add “Number01” to your fields.

Now, somewhere in your report, set a textbox equal to expression:

First(Fields!Number01.Value, "CallContextBpmData")

Save your .rdl, upload it, and you should see your report style number show up in the textbox. Copy the report style, use the same Custom Path (in my case, my first copy would be 1002, and my second copy 1003, set up identically)

If user prints from report style a, you should see 1002 in your textbox (1002.00000 because it’s a decimal vs. an int, but close enough!), and from report style b you should see 1003.

With that data now available, you can format your report conditionally to allow for the same RDD/RDL to output different visible presentation based on the report style printed, by using switch/case or if statements in your expressions.

4 Likes

Thanks, that’s exactly what I’m aiming for! Sounds like this is my way forward. I am however quite new to this and have never touched BPM’s. We predominantly use the on prem client, but when opening and using tracing in the browser, I don’t get any further info after selecting print. The closest I can see in there is Erp.Rpt.ARInvFormSvc so should I be looking for Erp.Rpt.ARInvFormSvc/SubmitToAgent?

That doesn’t seem to be an option in BPM designer, in fact there doesn’t seem to be many options at all in our BPM designer. Maybe I don’t have access to view them?

1 Like

Hi James,

From your screenshot, you are in the right place (method directives)
Click the search icon:
image

In the search, change “Type” to “Report” and “Service Name” to “ARInvForm” (the call in the network trace you saw to “Erp.Rpt.ARInvFormSvc” maps to System Code: ERP, Type: Report, Service Name: ARInvForm

Now hit search, and you should see all the methods that show up under ARInvForm. You want SubmitToAgent. Check the box next to it and hit ok

Then on the upper left hand side, hit the plus icon to create a new “Pre” directive

Set the directive details up something like this:

From there, you can drag in the custom C# code widget and paste in the code. (you would need to change it appropriately to work for the ARInvFormParam object, which should be the below)

callContextBpmData.Number01 = ds.ARInvFormParam[0].ReportStyleNum;

Then, hit save to save the custom c# code, then save again to save the bpm overall.

In your trace you should be able to see the full call including SubmitToAgent, you may just need to alter the options in the Network Tab of your F12 Dev Tools or click around a little bit to expose the right ui bits. The key bits of info are what URL is called (which you are seeing a part of) and what the payload/preview is (headers also sometimes hold important data) - suggest doing some learning with dev tools as this is a great resource for programming epicor.

Also, your Epicor URL ends in /apps/erp/home/, change this to end in /apps/resthelp and load that webpage, and login. This resource informs you how to “talk” to the BOs within Epicor. Do a search for “ARInvForm” and you will see Erp.Rpt.ARInvFormSvc - click into it, and click the “RPC” tab - in there, you will see the various methods that can be called including SubmitToAgent.

1 Like

Hi Gabe, that’s worked perfectly! Thanks very much for the clear instructions

1 Like