Comment Reporting API

 

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.

1. Grabbing the template_id

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:

{ "success": true, "message": "3 record(s) found", "data": [ { "options": { "sort": [ "groupName", "reviewType", "reviewerName" ], "includedProjectFields": [ "projectNumber", "address", "projectName", "dueDate", "startDate", "notes", "scopeOfWork" ] }, "id": 2, "jsReport_id": "H1ls_En1OH", "name": "Irvine Report Template", "title": "EPR Corrections Report", "logo": "https://epr-qa.s3-us-west-2.amazonaws.com/reportLogo/1570148452674Orange.jpg", "instructions": "Example Instructions", "createdAt": "2019-10-08T21:07:30.000Z", "updatedAt": "2019-11-13T16:42:16.000Z" }, ...] }

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.

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.

  • includedProjectFields: This will be an array of all project fields that will be included in the report.

 

2. Generating a report through the api

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):

{ "project_id": <project_id>, "template_id": <template_id> }

Including Closed Comments

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:

{ "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

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.

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.

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.

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.

 


Additional Report Options

Users can also now override sort order and included project fields through the report API like so:

This will override what is currently in the specified template.

List of valid sort order field names:

  • commentNumber

  • groupName

  • reviewType

  • category

  • reviewerName

List of valid project field names (projectNumber and address included by default):

  • projectName

  • contact

  • projectType

  • submittal

  • occupancy

  • constructionType

  • squareFootage

  • buildingHeight

  • applicationType

  • serviceArea

  • site

 


For additional information please refer to the swagger documentation at <portal>.eplansoftreview.com/api/core/ under Reports.