Login
Back to bricks list
Introduction Version

Dynamic reports



In Constellab you can generate report and dynamically include data (text and views) in it. This can be done directly in your pipeline to generate a formatted report that present your result. This guide will explain how to make an e-note and put data in it, then how to turn it into a Constellab report.



Create an enote


To create an e-note use the "Create e-note" task, view detail here. When creating a e-note you can choose to initialize it with a report template. 


Use parameters in report template


In the report template page, you can create and modify templates that can be used by the e-note.  In the template, you can mark spots where data should go using parameters.


To do this, select your text and click "Parameter". The text will turn pink.



ou can click on the parameter to change its name, description, and value.





That's it, you parameter is defined in your template, it will be possible to replace this variable with a text or a view in your pipeline. 


Modify e-note


To change an e-note, use a Python live task. In the task's code, you'll work with the e-note to add text and views. You can see what you can do with the e-note resource here.



As this is a python live task you can set multiple inputs in this task. We recommend to set the created e-note as the first input. Then you can add other input to fill the report with values of the resources passed as inputs (data or view). 



Replace variables


Use the set_parameter method to set the value of a parameter.


enote.set_parameter('text_variable', 'This is a value')

Add view


To add a view, there is 2 methods : add_default_view and add_view. Those methods support parameters which means that the view can be set at a parameters position in the e-note. 


Add_default_view


With this methods just pass the resource you want, the system will call the default view and add it to the e-note. The default view, is the view you see when you open the resource. 



Add_view


  With this approach, you can include a customized view of a resource in your report. To do this, you need to specify the view_method_name and config_values to set up the view. You can locate this information by opening your view and selecting "View settings" > "Show view configuration".  



Copy the value from the dialog and paste it on the add_view method. 


Add text to e-note


Use the add_paragraph method to create a new paragraph in your enote. 



enote.add_paragraph('New conclusion paragraph')

Exemple


Here is an exemple of a live task that manipulates an enote : 




Generate report from e-note


When your e-note is ready, you can export it to a report available in the report tab of your lab. To do so, use the 'Generate report from e-note' task, view information here.