I was looking at these two threads:
That got me to thinking about prepopulating data into a BAQ report.
I had a general idea of how it worked, but I dug in a little further so I could document for everyone.
When a report is run, report parameters are stored in the SysTaskParam
table for that report run, and you can have the system prepopulate these fields in a BPM.
For a BAQ Report, you can intercept the call in SubmitToAgent
, TransformAndSubmit
, and RunDirect
. Chose one or all that is most relevant to you, the code should be the same.
SubmitToAgent
is the async version mostly (only?) used in classic.TransformAndSubmit
is the async version of preference for the Kinetic UI.RunDirect
is the synchronous version, commonly used in custom code to retrieve to run a report directly and grab the data. (Examples everywhere)
Anyway, for the demo, I decided to imagine a scenario where I would want to bring down a common set of images for use in every report. Would you want to do this? I don’t know, but it sounded plausible so that’s what I did.
I wanted to be able to retrieve these images by a key, so the logical thing was to pass down json, as a Dictionary<string, string> object. They key is the “filename”, and the value is Base64 image data.
I put some sample images in Image Maintenance, and made them in a class called “sample”. They were all named “sample1”, “sample2”, etc…
I just gather that data in a pre-processing BPM, and populate the Character01 field in the BAQReportParameter DataSet.
This will get stored and passed to the report for use.
Now this left a little gap in capabilities, because SSRS does not support JSON out of the box. I have a little demo in another thread of how to get SQL to parse it for you, but that was a little overkill for what I wanted to do.
I decided to use VB.Net
in the report to grab the data from the dictionary json.
Well with a little “prompt engineering” in ChatGPT, I ended up with a nice little function you could add in the code section of an SSRS report. You can then call this little function and pass it the BAQReportParamter.Character01
value, and the “key” and it will give you back the image data.
=Code.GetDictionaryValue(First(Fields!Character01.Value, "BAQReportParameter"), "sample1")
And
Cool, it works.
I’ll show the code in the next post, but let’s keep in mind that this is a technique demo, and not necessarily a solution to a problem. (although it could be?)
You could use this technique to pass down both generic data like I did, or specific data, depending on the sophistication of your BPM and SSRS abilities and needs.