Extending Rest Services
To work with agency data in the mobile app, you must extend your Rest Services by editing the Rest Services configuration in the Configuration Editor. Specifically, you must add the agency data to the Rest Services models.
Like the mobile app, the Rest Services use models to define the data structures that different services will work with. A model in Rest Services may correspond to a single table in Infor Operations and Regulations, or it may include data from multiple tables. Models can also be linked to other models in hierarchical relationships, just as tables can be linked in the database.
One difference between models and tables is that different models are used for different types of requests. Typically there is one model for GET (query) requests and a separate model for POST (add) and PUT (update) requests.
For this example, we will extend two models to include the agency inspection data. The Inspection model is used for POST and PUT requests, and the InspectionResponse model is used for GET requests. To link the agency table to these models, the agency will add a model property to each of them.
Adding model properties
Model properties are defined under the node of the selected model. Each model property is itself a model that is linked to the main model in a parent/child relationship. The first step is to add a node for the agency table under . The only required attribute for this node is the Property Name, which can be set to any value the agency chooses.
When you add a new model property node, it has four children: , , , and .
The next step is to add a child mapping under the node, which maps the model to the agency table. These attributes are required for the mapping:
| Attribute | Description |
|---|---|
| Moniker | Specifies the moniker of the agency business object that the model is mapped to. In this case the moniker is InforClient.Details.InspectionDetail. |
| ID | The ID will be used to refer to this mapping elsewhere, and will represent the agency object. The value can be anything that the agency chooses. In this case the agency uses the same name as the object, InspectionDetail. |
| Relative Mapping ID | The Relative Mapping ID attribute of the mapping must be set to the name of the parent model, such as Inspection in this case. This is important because it tells the Rest Services that the mapping is not a product drill down, but rather an agency table that is linked to the Infor object. |
Adding component properties
The next step is to add the specific properties of the agency object that you want to include. These will be added as component properties of the model property.
The node is a child of the node under the model property. For this example the agency must add three properties. In addition to the NumberTimes ( # of Complaints) and CodeSection (County Code) properties, the primary key of the agency table must also be included. Each component property requires these attributes:
| Attribute | Description |
|---|---|
| Property Name | Used to assign a name to the property. This can be any name the agency chooses, but it will typically correspond to a property of the agency object.
Take note of the property name that represents the primary key in the agency table, because this will be required for the Mobile configuration. In this case the property name is Key. |
| Component Property Bind | Specifies the property of the agency object that the component property is bound to. The bind uses the mapping ID defined in the previous step, followed by the property you want to bind to, such as InspectionDetail.CodeSection. |
Testing the configuration
After you've saved your changes, you can restart IIS and test your configuration. The simplest method is to user your web browser to try a GET request. To look up a single inspection, use the QueryInspection service, as shown in this example.
http://server/rest services/api/CDR/inspections/CodeEnforcement/1001
The agency data should are displayed in the Extended Properties section near the bottom of the page. You can also use an HTTP client such as Postman for Google Chrome to test POST and PUT requests.