Field Definitions
Field definitions consist of four elements: name, type, length, number of places to the left or right of the decimal point for numeric values.
There are two types of field definitions: pre-defined and user-defined. Pre-defined field definitions begin with an underscore character (_) and are provided with the system. An example is "_Clock IN Time."
Prerequisites
There are no prerequisites for creating field definitions.
Pre-defined field definitions
The Activities system provides the following pre-defined fields for which you can create result codes. Result code fields are optional on activity forms to enhance result information.
- _Completed Quantity Code
- _Reworked Quantity Code
- _Scrapped Quantity Code
- _Reason Code
For example, for _Scrapped Quantity Code, you may want to create result codes to indicate reasons why material was scrapped.
Example
In this example, we create, verify, update, and delete a field definition.
Create a field definition
The create request:
- creates a new field definition named: Additional Quantity Code
- defines an alphanumeric field character length of 15
Example request
Call the Create Field Definition POST /v1/work/field_definitions
operation with the following request payload.
{
"name": "Additional Quantity Code",
"fieldLength": 15,
"fieldType": {
"id": 0,
"qualifier": "Alpha numeric"
},
"active": true,
"resultCode": true,
"multiSelect": false,
"resultType": true,
"version": 1,
"default": false
}
Example response
A success response returns HTTP status code 200 and a response body similar to the following example.
{
"id": 1,
"name": "Additional Quantity Code",
"fieldLength": 15,
"fieldType": {
"id": 0,
"qualifier": "Alpha numeric"
},
"active": true,
"resultCode": true,
"multiSelect": false,
"resultType": true,
"version": 1,
"default": false
}
Verify
To verify, call Retrieve Field Definition by ID GET /v1/work/field_definitions/{id}
or Retrieve All Field Definitions or by Name GET /v1/work/field_definitions?name={name}
.
Calling GET /v1/work/field_definitions/1
or GET /v1/work/field_definitions?name=Additional Quantity Code
returns:
{
"id": 1,
"name": "Additional Quantity Code",
"fieldLength": 15,
"fieldType": {
"id": 0,
"qualifier": "Alpha numeric"
},
"active": true,
"resultCode": true,
"multiSelect": false,
"resultType": true,
"version": 1,
"default": false
}
Note: GET /v1/work/field_definitions?name=Additional Quantity Code
returns the object above enclosed in an array, since omitting the name
query parameter returns all field definitions in the system.
Update the field definition
To update the field definition to increase the field length to 20, call Update Field Definition by ID PUT /v1/work/field_definitions/1
with the following request payload.
Example request
{
"id": 1,
"name": "Additional Quantity Code",
"fieldLength": 20,
"fieldType": {
"id": 0,
"qualifier": "Alpha numeric"
},
"active": true,
"resultCode": true,
"multiSelect": false,
"resultType": true,
"version": 1,
"default": false
}
Example response
{
"id": 1,
"name": "Additional Quantity Code",
"fieldLength": 20,
"fieldType": {
"id": 0,
"qualifier": "Alpha numeric"
},
"active": true,
"resultCode": true,
"multiSelect": false,
"resultType": true,
"version": 2,
"default": false
}
Note that the version is automatically incremented to 2. To successfully update this field definition again, you must pass version 2 in the request body.
Delete the field definition
To delete this field definition, call Delete Field Definition by ID DELETE /v1/work/field_definitions/1
.
The system returns HTTP status 204 with an empty response body.
Updated over 1 year ago