Part 4: Updating Silent application to process a Case
At this stage there is a new case with a payload that needs to be processed. By the end of this section the payload of the case will have been retrieved, processed and the status of the case updated.
4.1 Refactoring Main Decision Flow
- Open Main_Decision_Flow in the Process Expenses application.
- Highlight Expenses and click the Copy button
- Right-click on Expenses and add a new decision flow tree call Process_Case with no Split
- Open Process_Case and paste in the buffer and save
This will essentially paste in the contents of Main Decision Flow into this new Process Case Decision Flow
- Open main decision flow, highlight expenses and delete it
- Set the Empty node to done
The only object in Main_Decision_Flow is Process_Case
4.2 Retrieve the Case
4.2.1 Import the SolutionID
In a previous section the Library Build tool was used to add object shortcuts from Employee Expense Application to Process Expenses where the objects were originally created. This can work both ways as the solution ID was originally created in the Employee Expense application but is now required in Process Expenses
- Open the Library Category in Build Tools and double-click "Add an Object Shortcut"
- Follow the instructions on each page to import an Object
* Select Knowledge-base "Employee Expense Request"
- Select Object: "SolutionID"
- Select Category: "Questions & Attributes"
- Import Mode: "Linked Copy (read-only)"
4.2.2 Querying the Cases
Using the query cases Build tool, all cases that match a certain criteria e.g. Status can be retrived into a text object. This text object is an array so it is possible to one or all of them.
From within the Main_Decision_Flow Tree editor:
- Drag in the "Query Cases" Build tool onto Process_Case
- Select Create New Object
- Name: "CaseID"
- Category: "Question & Attributes"
- Description: "Retrieve Case"
- Select: "SolutionID" for the Solution ID
- Status: "New"
- Query: clear it as Status of "New" will filter the cases.
This will set "CaseID" to be an array of cases, but we only want one case, i.e. the next one in the list. To do this we need to edit the OnCapture JavaScript.
- Right-click on "Retrieve Case" and select Edit Advanced settings
- Overwrite the on capture event code with the code below, click OK and then Save.
let cases = xpertrule.cases.filter(#SolutionID.val(),null,'New',false);
if (cases.length>0){
#CaseID.val(cases[0]);
}
If there are no cases in the array, no processing is required. To cater for this event do the following.
- Drag "CaseID" onto Process_Case and mutliway split
- Move Process_Case to the otherwise branch
- Double-click on Matches with branch and select include allow blank values in this branch
- Set "Is Blank" branch to "Done"
- Change empty leaf nodes to "Done"
- This completes the refactoring of Main_Decision_Flow and retrieve a case. The case can now be processed in Process_Case