GetCases, which builds the array, and GetCaseDetails, which supplies each case’s details.
Create the GET method
1
Start a new Service REST
Click Records → Integration Resources, right-click Service Package, and then click the Create command on the shortcut menu.
2
Specify the service details
On the form that opens, specify the following values, and then click Create and open.
3
Open the GET method
On the Methods tab, expand the GET method.
4
Create the response conditions
Click the Response tab and create the two conditions described in Response conditions.
Response conditions
Create the following two conditions on the Response tab.pxIsInternalError
Parameter values:- Condition:
When - When name:
pxIsInternalError - Content type:
application/json - Status code:
Param.StatusCode
Success response
Parameter values:- Condition:
Default - Content type:
application/json - Status code:
Param.StatusCode
- Name
etag, with Map from set toClipboardand Map from key set toParam.eTag - Name
cache-control, with Map from set toConstantand Map from key set to"no-cache"
- Description:
Response - Map from:
Clipboard - Map from key:
Param.Response
Create the GetCases activity
1
Create the variables
On the Parameters tab, create three variables:
resultof typeStringcurrentCaseIdof typeStringtempResultof typeString
2
Get the list of available cases
Call
Call pzGetCasesByFilter and select the Pass current parameter page option.pzGetCasesByFilter writes all the cases to myStepPage.3
Loop over the returned cases
Create a step with a
Property-Set method that returns cases from myStepPage in a loop.- Add a loop and select For each element in value list.
- Specify the myStepPage.cases property.
- In the method parameters, set the
Param.currentCaseIDvariable tomyStepCase.cases(<CURRENT>).ID.
4
Get the details of each case
- Type
Call GetCaseDetailson the Method tab. - Type
myStepPage.cases(<CURRENT>)in Step Page. - Set the caseID parameter to
Param.currentCaseID.
5
Store the result as a string
Convert the result obtained in the previous step into a string and write it to the
Param.tempResult variable.6
Add the JSON separator
To generate a valid JSON string, add a comma to the
Param.result parameter, which is Param.result + ",".In the When field, add the following two conditions:- If
@IsParamBlank(tools,"result")istrue, Skip Step. If the parameter isfalse, Continue Whens. - If
@IsParamBlank(tools,"tempResult")istrue, Skip Step. If the parameter isfalse, Continue Whens.
7
Append the case to the result
Check whether tempResult is empty. If it is not empty, add the value from tempResult to the main result, which is
Param.result + Param.tempResult.8
Build the final response
Create the final response
"["+Param.result+"]" and write it to the Param.Response variable.Create the GetCaseDetails activity
1
Create the variables
On the Parameters tab, create three variables:
caseIDof typeStringfileNameof typeStringlistFileNameof typeString
2
Declare the page
Open the Pages & Classes tab and add a page named
Case of the Work- class.3
Open the case
On the Steps tab, type
Obj-Open-By-Handle in the Method field. Add Case in the Step page field, and type Param.caseID in the InstanceHandle parameter.4
Create the attachments property
Create a new
.attachments property and populate it with the Case.pyAttachments list.- Click the target icon on the right, and then click Create and open on the Create Property form.
- Select Page List as the property type.
- Type
Link-Attachmentin the Page definition field.
5
Populate the page with content values
Write
Page-Copy to the Method field, Case to the CopyFrom field, and .content to the CopyInfo field.