You can help by commenting or suggesting your edit directly into the transcript. We'll review any changes before posting them. All comments are completely anonymous. For any comments that need a reply, consider emailing firstname.lastname@example.org.
We are experiencing playback issues from our video hosting provider. Please check back shortly.
2:09Scheduling Actions - Save
3:15Scheduling Actions - Email
Take topic challenge
In this lesson we'll look at two new scripting functions that allow you to run your report, as well as an extension function on the Ignition 7.8 Report Viewer component
Video recorded using: Ignition 7.9
Transcript(open in window)
[00:00] Let's take a look at some of the scripting functions available for Porting Module. You see on this very simple report setup here, just showing our function name parameter here. If I take a look at the data panel, we'll see that it's just an empty string. So, we're going to go ahead and use this in a couple examples here. We'll scroll up in the project browser. We'll take a look at our execute report window. Now, this window will have an empty PDF viewer. There's no bindings, it's not set to any report right now. And then we have a script on this button here. Open up the scripting menu, and take a look. And you can see we're using system.report.executeReport. Now, this function returns a byte array of the report. You can do all sorts of things with these bytes, like store them in your database or pass them directly into the PDF viewer, which is what I'm going to do here. When using this function, you need to specify the path, so this is the path in the project browser to the report. Next, you pass the project name that the report resides in. And then you can override any parameters like I'm doing to functionName here. And then you need to specify a format. The way we're getting it into the PDF viewer is we're using this load bytes PDF. That's on the PDF viewer component. Let's click okay and put the designer into preview mode. We'll click the button, and there's the report. And as you can see, our parameter's been overridden, and it's showing up on our report. Next, let's take the designer out of preview mode. We'll head over to my execute and distribute window, and we'll take a look at this execute and distribute button. We'll right click, and take a look at the scripting. So this is using system.report.executeAndDistribute. Now this takes execute report a little further. It doesn't return anything, but it does run an action on the report, so you can email, print, save to an FTD server, or save the report locally. Now this happens immediately, so you can have your users run an action on a report without them having to enter the designer. Now, remember, reports run in the gateway, so when you call a save action like this, it's going to be relative to the gateway. All I'm doing here is I'm specifying which reports, the script report again, the project name for report. I'm overriding my parameter, my functionName parameter here. There's an action argument, that's just saying I want to save this. And then there's some action settings. Now, the action settings are going to be different depending on whatever action you're using here. So the action settings for save would be the path to wherever I want the file to be saved, whatever I want the file to be named, and then what format I want to save it in. So, let's give it a shot. We'll click okay. We'll move the designer out of the way a little bit. Let's hit the preview mode. Click our button. There it is. We'll open this up, and here's our report. We'll close this, and we'll head back to our designer. I'm going to take the designer out of preview mode. And, the last thing I want to show you is an extension function on the report viewer component, so I'll drop on over to the window here. We'll right click, go into scripting, and you see there's this onReportGenerated extension function. This is triggered every time the report's generated, so changing the report path, for example, would trigger it. Changing a parameter on the report viewer component, that would trigger it. So, say for example, you wanted to use our message handlers to let everyone know our report's been generated, or write to a tab when our report's been generated, or something to that effect. You can go ahead and do that right here.