Aris Scripting Tutorial – Part 10 – Matrix with Enhanced Dialog
Ready for the next tutorial in this series? Let’s enhance the matrix report a bit by adding some more functionality to the dialog. Assume that I have received the following additional requirements:
- It should be possible to hide default attributes (creator, time of generation, last change, last user)
- Highlight changed values should also become an option
- If a whole model with many different object types is selected, it should be possible to show just some object types in the report
- Full support to select multiple models
A) Hide Default Attributes
We take the approach to reduce the list of attributes by a predefined selection of default attributes.
This will be achieved by defining an array and adding all attribute types that should become hidden:
Based on this array we limit then the list of attributes in case this option has been set:
This parameter will become our first under "General Options":
B) Highlight changed Values should become an option
This is another option we offer. In case the ‘highlighting’ is requested, a certain format style will be selected (red), otherwise just the usual black.
This option will be displayed as our second option:
C) Show just some Object Types
This is from all given requirements the most complex. Although you start the report from models with a lot of different object types, you like to see only a limited number of them. Because we can not know in advance which object types are requested, we build the list dynamically and offer a section with checkboxes to the user. This section will automatically expand and flow over into the second row after the first 4 types.
The following code is needed to implement this. Right after the start we build a new list with all selected object types by looping through all object occurrences (1). This list becomes also unique (2). With this information we open afterwards the dialog (3).
By taking the incoming type array we build now a dynamic list of check boxes inside the dialog function.
This dynamic approach needs to be incorporated also in the following dialog code lines to track selected values for reuse.
When closing it loops through all check boxes and adds the selected object attributes to a new result set.
Object occurrences initially found will be reduced now with the result set from the previous step.
The complete dialog can look like this:
Note: you can find another code element to validate if at least one object type is selected. In case none, a message will appear and inform that a selection is required (see code lines 273-276).
Now, as we have everything ready for the layout and the data content, the report can be created. A possible output for EPC models with object type "Function" selected might look like this:
D) One final Correction: Support Multiple Model Select
There is one final correction in place. I created a new function out of some repeating code, placed it into our shared library “Common Reporting Functions.js” and use it from now on in all reports.
It has been changed slightly on the end to allow now also a multi select of models.
The command to call it is here, right on top of our main() function:
With these techniques you can improve your matrix report and make it more complete and user friendly.
Please download the final report file from here for your own review.
If you like try to implement the following (from simple to more complex):
- Add more common attributes into the category ‘Default Attributes’
- Add a function to change the date format according to your selected language
- Add an option to hide rows if all values are the same
- Write also the attribute type into a new second column
- Remove the frame around the title
- Support to call this report from a group
You may consult the script help to find the right options or functions to use.
I will close the report part with this enhanced matrix. By following all of the tutorials you should have got a good set of procedures and techniques to develop your own reports. As next I like to add some more tutorials for specific topics, like providing an alternative way to validate object attributes.
Please feel free to ask any question or give any kind of feedback!