In Odyssee, you can fill report (form) on different entities, like on a Work Order (entity=jobs).
These reports are based on the Info Fields system.
All these reports are saved on the table db_report
and available on the API to let you extract the information you need.
Because it's a bit more complex that en entity with few fields, you will find on this page some explanation about how to extract these information.
The field db_report.db_report_type_id
is the foreign key to the admin table db_report_type
that contains the list of all the types of reports.
It is the report type that defines what are the chapters and the fields.
Creating a report on an object (like a Work Order) saves the line on table db_report (user_id,date_start,description
).
The information filled on the fields are saved into the table db_info_data
, as how it's working for Info Fields.
Because all the reports (so the form filled) are saved into one single table, we need a way to only retrieve reports created on 1 entity (like "The reports on this JobsId").
To do that, the table uses the common method with 2 fields : db_table_id
and id_in_table
.
- db_table_id
:contains the ID of the table of the linked object (Example for a Work Order Report : 8FBBD742-A3B1-439A-898A-16541AD8E7EF).
- id_in_table
:contains the ID of the linked object (For a Work Order Report, it will contains the jobs.id
value.
Let's take a real situation as example : The reports created on a Work Order need to be imported on the ERP when the work order is approved.
Let's see the different calls to have the chapters, then the fields and finally the value.
Find the db_report:
We will list the db_report created on my Work Order that was just approved (jobs.id=f5934eb2-0f73-41a2-b726-12601dff35cb
).
Request URL :
api/DbReport?$select=id,db_report_type_id&$filter=db_table_name+eq+'jobs'+and+id_in_table+eq+f5934eb2-0f73-41a2-b726-12601dff35cb
Result :
{ "@odata.context":"https://developers.odysseemobile.com/api/$metadata#DbReport(id,db_report_type_id)","value":[ { "id":"1f3d825e-1422-4f9a-a96f-82b56c5dd9df" ,"db_report_type_id":"36c652a8-3006-43f5-9b27-6a799cc7b8b7" } ]}
Find the chapter:
As we can see, we have 1 report that has been created on ths Work Order. We will now grab the chapter.
Thanks to the db_report_type_id, we can uses the InfoFields (The field db_info_category_id
=db_report_type_id
).
Request URL :
api/DbInfo?$select=id,name&$filter=db_info_category_id+eq+36c652a8-3006-43f5-9b27-6a799cc7b8b7&$orderby=sequence+asc
Result :
{ "@odata.context":"https://developers.odysseemobile.com/api/$metadata#DbInfo(id,name)","value":[ { "id":"1c7ec17c-fd6d-4716-8aca-c482c69a8f41" ,"name":"Header" }, { "id":"efbca0da-cb8b-4b31-b1ef-cd97d0c5baa2" ,"name":"Details" } ] }
Find the fields and the values
We have 2 chapters , Header and Details. All is now about the InfoFields logic.
To list the fields, make a call on controller /api/DbInfoField and filter on the db_info_data.
To list the value of the field, make a call on controller /api/DbInfoData, specify the db_info_field_id
previously found AND target_id
should be your db_report.id
retrieved on the first call when listed the db_report.
That's ALL !