The following routes are considered legacy and should not be used:
/resources/reports/create
/resources/reportTemplates
/resources/reportTemplates/{id}
/resources/reports/pdf
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> }
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": { "closedComments": <boolean> //true or false } }
3. Finished!
If the report was successfully created you should see something similar to the following:
{ "success": true, "message": "Attachment created and stored", "data": { "vendor_id": null, "id": 38, "project_id": 9, "filename": "Eric's report.pdf", "updatedAt": "2019-11-18T22:58:44.416Z", "createdAt": "2019-11-18T22:58:44.416Z" } }
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 (Experimental)
Users can also now override sort order and included project fields through the report API like so:
{ "project_id": <project_id>, "template_id": <template_id>, "options": { "sort": ["groupName", "category", "subCategory"], "includedProjectFields": ["occupancy", "buildingHeight", "submittal"] } }
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.