Very custom reports!!

Vault comes with great reporting functionality, which allows you to generate reports from all the Vault entities, including custom objects. In a recent project, we had the need to go beyond the standard features provided by the Vault reporting, and so we extended the Vault reporting via Data Standard.

For this post, I’ve prepared a simple example. I’d like to create a report from an assembly and display parts only. For each part, I’d like to see whether an item is assigned or not. Additionally, I’d like to have also the folder name printed on the report. This is how it looks like:

2014-02-25_16-47-13

In order to get this done, we developed a small DLL (cOreporter) that embeds the same reporting technology like Vault (Microsoft Reporting). The class cOreporter requires 3 arguments: the file to the RDLC (report template), a data source (DataTable) and some optional parameters that should be printed on the report.

In order to call the reports with Vault, we leverage a functionality of Data Standard. You can configure additional menu items and have a PowerShell script behind, running some code. So, we basically added a new menu item in the myMenu.mnu file and wrote some code with the Vault API in our PowerShell script in order to collect the parts only, with according item information and some folder information. All these information are then passed to the cOreporter and voilà, we have all our data nicely formatted and ready for printing!

Let’s have a look to the menu item first. The myMenu.mnu is located in the Data Standard/Vault/ folder. You can edit it with a simple text-editor. There are basically 2 sections of the file. The first describes the menu item itself, while the second defines where the menu item shall be placed in the Vault user interface. Those, who are familiar with the Vault API, will quickly recognize the syntax, for all others, don’t panic, it’s pretty simple. Here is the definition for our menu item:

item cOpartList
{
 Description = "Parts only Report";
 Id = "cOprintPartReport";
 Hint = "Parts only report...";
 Label = "Parts only report...";
 MultiSelectEnabled = false;
 NavigationTypes = [File];
 ToolbarPaintStyle = TextAndGlyph;
 PSFile = "cOpartList.ps1";
 Image="co.ico";
}

The most relevant element in this menu item is the PSFile which points to our cOpartList.ps1, the PowerShell file located under ../addinVault/Menus. In this case I have added this menu item in the context of the file, as for the following section:

site fileContext
{
 Id="DSSiteFileContext";
 Label="myMenu";
 DeployAsPulldown=false;
 Location=FileContextMenu;
 MenuItems=[$newFile, $editFile,$cOpartList];
}

You’ll notice that in the element MenuItems, there is a reference to our menu item called cOpartList. So, next time you will restart Vault, you will have this menu entry:

2014-02-25_17-07-29

Now, let’s have a look to the cOpartList.ps1 PowerShell file. This looks a bit more complex, but in reality there are just 2 lines responsible for the reporting – the last 2:

[System.Reflection.Assembly]::LoadFrom("C:\ProgramData\Autodesk\Vault 2014\Extensions\DataStandard\Vault\addinVault\Menus\cOreporter.dll")
$report = New-Object cOreporter.cOreporter("C:\ProgramData\Autodesk\Vault 2014\Extensions\DataStandard\Vault\addinVault\Menus\partList.rdlc",$dt,$params)

The first one is loading the cOreporter.dll, while the second starts the reporting. You can see that the arguments for the cOreporter are the full path to the RDLC file, the Data Table and the parameters. The upper part of the PowerShell is just responsible to talk with Vault and collect all the information needed for the report. Depending on how simple or complex your need is, this part might be shorter or longer.

Bottom line is that now you have the freedom to add a menu item into the Vault user interface via Data Standard, have that menu item run your personal PowerShell code and if you like the cOreporter, you can create the most fancy reports you could think of!!

Here is the package with all the files: download!

For those who are interested in getting more insight into the cOreporter, we have shared the code and some more samples on GitHub.

This entry was posted in Free apps, Vault API. Bookmark the permalink.

10 Responses to Very custom reports!!

  1. This looks fantastic. Just what we needed. Thanks so much.

    • marlenebleicher says:

      Thanks, we’re really happy to help!
      If there are any other topics you’d like us to cover on the upcoming Data-Standard-fridays, just send in your suggestions here!

  2. Doug Redmond says:

    FYI. The Vault Explorer client and cOreporter.dll link to a different versions of the Microsoft Report viewer libraries. So if the custom command doesn’t pop-up a report, here is how you can fix the problem.

    Fix 1 – Download and install the Report Viewer 2012 Runtime from the Microsoft website.

    Fix 2 – Open up the cOreporter project in Visual Studio. Change the Microsoft.ReportViewer references to use version 10 instead of version 11. Rebuild and re-deploy cOreporter.dll.

  3. Thanks, Marco! That’s has been a great entry point. To get in line with the report format 2005/2008 used by Vault, I replaced the viewer control by the 2008 version one. In addition I added error handling, in case your report is just under development and returns messages, what you need to change in your template.

  4. Heiko Mertens says:

    Hello, maybe I didn’t see it but how can I “install” this Addin to my Vault? I downloaded the Files and now I don’t know what to do next with them. Please help….

    • Marco Mirandola says:

      Hi Heiko, a pre-requisite for this tool is that you run Vault Data Standard. So, if you have VDS installed on your Vault, you should have a folder called C:\ProgramData\Autodesk\Vault 2014\Extensions\DataStandard\, where the Vault version might be different. If that is the case, then you can just copy&paste the content from the ZIP file, actually only the “Data Standard sample\Vault”, into the according Vault folder within Data Standard. Next time you start Vault, you should see the menu item. Now, the sample on this post should work right away, however, it’s meant to be a base line for creating even more cool reports. We are planning to create a little free app for the app store that comes with a set of useful reports. If you have some ideas, please share it. Thanks!
      In case you experience more issues, you may reply here, or if it’s getting too long, then just reach out to our support at support@coolorange.com.

  5. Thanks for making this tool available.

    Does the DataTable parameter have to be set or can it just be null (and presumably filled from SQL)? Your example doesn’t make mention of it, but it does specify a $dt parameter in the script which is not initialized.

    Taking a look at the source, it appears this values is expected and not null (based on the line: report.dataTables.AddRange(table);) but what should it be set to?

    • Marco Mirandola says:

      the DLL we’ve created is a wrapper for the Microsoft Reporting engine, and so far the argument DataTable is mandatory. Obviously you can create an empty DataTable and pass that one, but the argument cannot be null. The idea is that you collect the information you like into the DataTable and then report on that table. If you have a single page report where you only report a set of fixed values, you can use the params and keep the DataTable empty, nut not null. Alternatively you are welcome to download the source of the DLL from GitHub and change it the way it’s most appropriate for you. I hope this helps. If you need further assistance, drop an email to our support.

  6. has this been updated for Vault 2017? if so how do I install this app?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s