Hi, all! Welcome back to the continuation of our Primer posts on SWQL and the Orion® SDK. In the last post, we established how to create a query, and how to link tables together to get useful information. In this post, we’re going to discuss how to apply these to your Orion Platform products.
If you don’t feel entirely comfortable creating a query, I highly encourage you to read over the last post. It serves as a foundation for today’s discussion.
The first and most obvious application for SWQL queries is generating Orion reports in the web-based report writer. To start, go to Reports à All Reports, then select “Manage Reports” in the upper right corner:
From here, click on “Create New Report”:
If this is your first time creating any report, you will see a nice splash page on how to create reports. I highly recommend you read it over to get an idea of the process, and when you’re finished, go ahead and close to proceed with the remaining steps.
The first page you see when you create a report is Add Content. For what we’re doing, there really are only two options, Custom Chart and Custom Table. Since we’re going to use the example from the previous post, let’s select the “Custom Table” option.
Once selected, you are asked to add your data source. This is where our SWQL magic comes into play; change the Selection Method from “Dynamic Query Builder” to “Advanced Database Query (SQL, SWQL)”:
Make sure the radio button is set to “SWQL” so Orion knows which language to construct from. From here, let’s copy and paste our query from the previous post into the big box. Then click on “Preview Results” to make sure everything is working correctly. Note: this will not show you all results, just a small selection:
Once that’s complete, click “Add to Layout,” which will automatically send you to the custom table formatting table. Here you can add the columns from your query into the report:
Now that your columns are added, you’ll see the table layout section. Use the dotted icons to arrange the columns in any order you want (1). You can also expand on the column to change their name (2) to something friendlier, such as “System Name” instead of “Caption” (3):
Once you’re finished, click “Submit” to finish the table. If you wish to add more tables, or if you charted something, you can add more resources to the page. Otherwise, you can finish your report as you would normally.
That wraps it up for now. Next time we’ll continue exploring how to apply SWQL queries into widgets in the dashboard. Thanks for reading!