Execution of Grid Requests
To explain how to execute Grid Requests, an example will be presented in this section.
Structure
The goal of this Example is to retrieve the Activities in Work Orders that either have trade *
or no Task Plan set, meaning that they have less than 10 estimated hours and are ordered in a descending way for the required people.
Comments from Sara
Rows of what? I don't understand exactly where these rows come from.
Also, the example is not very clear for entry level users I think.
Grid Structure
The structure of the Grid Request Example is displayed below (after ignoring the first two rows).
Grid Name: | WSJOBS_ACT | ||
---|---|---|---|
Parameters: | param.jobnumber:WORK_ORDER_CODE | ||
Filters: | F1 | Column Name: | trade |
Operator: | = | ||
Joiner: | OR | ||
Left Parenthesis | true | ||
Right Parenthesis | false | ||
F2 | Column Name: | task | |
Operator: | IS EMPTY | ||
Joiner: | AND | ||
Left Parenthesis: | false | ||
Right Parenthesis: | true | ||
F3 | Column Name: | esthrs | |
Operator: | < | ||
Value: | 10 | ||
Joiner | AND | ||
Left Parenthesis | false | ||
Right Parenthesis | false | ||
Sorting: | Column Name: | personsreq | |
Direction: | DESC | ||
Row Count: | 3 |
Syntax
Below, the syntax needed to execute this Grid Request in the different Web Services will be shown.
SOAP
For calling this Grid Request with the SOAP Web Service, it is possible to use the Endpoint getGridResult
, whose definition can be consulted in SoapUI. Using the Structure available there, it is also possible to write the Example's Request. In the code below, this Syntax is presented.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsh="http://cern.ch/cmms/infor/wshub" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soapenv:Body>
<wsh:getGridResult>
<gridRequest>
<gridName>WSJOBS_ACT</gridName>
<userFunctionName>WSJOBS</userFunctionName>
<params>
<entry>
<key>param.jobnum</key>
<value xsi:type="xsd:string">WORK_ORDER_CODE</value>
</entry>
</params>
<gridFilters>
<gridFilter>
<fieldName>trade</fieldName>
<operator>=</operator>
<fieldValue>*</fieldValue>
<joiner>OR</joiner>
<leftParenthesis>true</leftParenthesis>
<rightParenthesis>false</rightParenthesis>
</gridFilter>
<gridFilter>
<fieldName>task</fieldName>
<operator>IS EMPTY</operator>
<fieldValue></fieldValue>
<joiner>AND</joiner>
<leftParenthesis>false</leftParenthesis>
<rightParenthesis>true</rightParenthesis>
</gridFilter>
<gridFilter>
<fieldName>esthrs</fieldName>
<operator><</operator>
<fieldValue>10</fieldValue>
<joiner>AND</joiner>
<leftParenthesis>false</leftParenthesis>
<rightParenthesis>false</rightParenthesis>
</gridFilter>
</gridFilters>
<gridSorts>
<gridSort>
<sortBy>personsreq</sortBy>
<sortType>DESC</sortType>
</gridSort>
</gridSorts>
<rowCount>3</rowCount>
<cursorPosition>3</cursorPosition>
</gridRequest>
<credentials>
<username>NICE_USERNAME</username>
<password>NICE_PASSWORD</password>
</credentials>
</wsh:getGridResult>
</soapenv:Body>
</soapenv:Envelope>
Warning
Note that the operator <
has to be escaped to <
, as it would conflict with the angle brackets (<
) normally used in the XML Format.
Also, the Object Type for the Parameter Value must be declared as a string, so that it is interpreted as one (xsi:type="xsd:string"
). Make sure to include the xsi
and xsd
namespaces as soapenv:Envelope attributes
.
REST
To call this Web Service, it is possible to use the /grids/data
Endpoint, whose definition can be seen in the Swagger Documentation. Below, the Request Body for this Grid Request Example is displayed.
{
"gridName": "WSJOBS_ACT",
"userFunctionName": "WSJOBS",
"params": {
"param.jobnum": "WORK_ORDER_CODE"
},
"gridFilter": [{
"fieldName": "trade",
"fieldValue": "*",
"operator": "EQUALS",
"joiner": "OR",
"leftParenthesis": true,
"rightParenthesis": false
}, {
"fieldName": "task",
"operator": "IS EMPTY",
"joiner": "AND",
"leftParenthesis": false,
"rightParenthesis": true
}, {
"fieldName":"esthrs",
"operator": "<",
"fieldValue": 10,
"joiner": "AND",
"leftParenthesis": false,
"rightParenthesis": false
}],
"gridSort": [{
"sortBy": "personsreq",
"sortType": "DESC"
}],
"rowCount": 3,
"cursorPosition": 3
}
The user must place this code in the Body in the Swagger Interface in order to create a REST Request.
When the Endpoint is runned, the following response rows appear under the Row Key. A Row is then represented by a List of Cell Objects.
The Response Cells for the Grid Request consist of the following parameters:
value
: value of the field;t
: description of what the field contains;n
: field ID;order
: order of the field.
The way these parameters are displayed can be seen below:
Metadata
There is also possible to include Metadata on the Request. This allows for the Response to include Information regarding all Dataspies available for the current Grid and the Fields that the Response will contain.
Regarding the SOAP Web Service, we need to add a specific tag to include the metadata <includeMetadata>true</includeMetadata>
when performing the Grid Request.
As for the REST Web Service, we need to include "includeMetadata": true
in the Request Object.
Above in the Example, when a Grid Request is performed for the grid OSOBJA
with include metadata, the Swagger Interface will return all the associated Data.