Note |
---|
The new comment report route /resources/reports/generate should be used starting with EPR release 2.2.0. Beginning with this release, the following routes are considered legacy and should not be used:
|
In addition to creating corrections reports through the EPR app, clients and third-party integration companies can also generate reports through our API route. Generating a report through the api only requires two parameters: project_id and template_id. This article will walk you through how to generate the report through the API with the correct parameters.
...
Report templates hold all configurable information that reports can have. This includes the report title, instructions, logos, included project fields, and sort orders. In order to know which template_id to use, you may need to query all reports and choose which template to use from the list of results. To do so, you should first make a GET request to /resources/reports/templates.
You should see something similar to the following result:
...
Each template in the list of results holds all the information that will be used to generate the report. The options field holds additional options that may not be apparent: sort and includedProjectFields:
sort: The sort object is a three-element array that defines the grouping and sort order that the comments should follow in the report. The first element in the array specifies which comment field the comments should be grouped by within the report. The second and third elements then define how the comments within each group should be sorted, with precedence given to the second field in the array.
Info |
---|
Suppose the sort option for a template was ['category', ‘subCategory’, ‘reviewerName’]. In this case comments would be grouped by their category. For example, their could be a list of comments grouped under the Civil , and another group of comments grouped under Structural category. Within each of these categories the comments will be ordered alphabetically according to their subCategory. In the case that two comments within the same list have the same subcategory, the comment with an earlier reviewerName(alphabetically) will be displayed first. |
...
Once you’ve found the id of the template you would like to use you can simply make a POST request to /resources/reports/generate with the following request body (JSON):
...
Including Closed Comments
Info |
---|
This format for this api has changed. Please refer to the example below. |
You can also provide an optional parameter in the request body to specify whether or not to include closed comments in the report. By default, closed comments are filtered out in the corrections report. You can add this option like so:
Code Block | ||
---|---|---|
| ||
{ "project_id": <project_id>, "template_id": <template_id>, "options": { "comments": { "closedComments": <boolean> } } } // old method // below is the old method of grabbing closed comments. // although it still works, it will be phased out in the future { "project_id": <project_id>, "template_id": <template_id>, "options": { "closedComments": <boolean> } } |
Filtering Comments By Label
Info |
---|
This format for this api has changed. Please refer to the example below. |
There may be times where you have multiple external statuses pointing to an internal status (e.g. Open and Approved w/ Comments both point to the ‘Open’ internal status) and want to filter comments to only show if they have a specific external status.
Beginning with the 2.3.4 Release of EPR, you can add the excludedLabels parameter inside of the ‘options’. This optional parameter will be an array of external status labels that you want to filter the report comments by. If specified, comments whose label matches one of the labels in the array will be excluded from the report. This filter stacks with the ‘closedComments’ option. If the ‘closedComments’ option is set to true and the ‘excludedLabels’ array is specified, the api will first grab all the comments for the project, then filter out those in the excludedLabels.
Code Block | ||
---|---|---|
| ||
{ "project_id": <project_id>, "template_id": <template_id>, "options": { "comments": { "closedComments": true, "excludedLabels": ["Open"] // Comments with label 'Open' will be excluded from the report } } } // old method (will still work but will be phased out in future) { ... options: { "excludedLabels": ["Open"] } } |
Include Only Comments With Attachments
The following example will generate a report and filter out any comments that do not have attachments. If you want to also include the links to those attachments for users to download, you can do so using the includeAttachmentLinks options. Note that this options can be used independently of one another.
Code Block |
---|
{ { "project_id": <project_id>, "template_id": <template_id>, "options": { "comments": { "withAttachmentsOnly": <boolean> // filter out comments without attachments "includeAttachmentLinks": <boolean> // include attachment links in the report } } } |
Specifying Report Filename
By default, the corrections report that is generated will be saved to the Project Attachments using the report title as the filename. Users can specify a filename parameter in the options to choose the name of the file that is saved to the attachments.
All reports are saved as .pdf files so please do not include the extension in the parameter.
Code Block |
---|
{
"project_id": <project_id>,
"template_id": <template_id>,
"options": {
"filename": "ChangedFilename" // attachment will be saved as ChangedFilename.pdf
}
} |
3. Finished!
If the report was successfully created you should see something similar to the following:
...
Users should then be able to check the attachments tab for that particular project and download the attachment that was created.
...
...
Although available to use, the following feature is still experimental and is not currently recommended
...
Additional Report Options
...
Users can also now override sort order and included project fields through the report API like so:
...
For additional information please refer to the swagger documentation at <portal>.eplansoftreview.com/api/core/ under Reports.