My Orders and Reports allow multiple sales people, managers, and admins to view RepSpark orders in My Orders as well as ERP orders in Reports and Invoices.
For My Orders, the information needed to support this hierarchy comes from the ParentCode field in the Options API call. The top of the hierarchy has ParentCode set to NULL as they do not have anyone above them.
Here's a simple example.
- A (highest level)
- B (no children, one level deep)
- C (one child, one level deep)
- D (no children, two levels deep)
KeyCode ParentCode
A NULL
B A
C A
D C
For reports and invoices, the information needed is not represented as a recursive tree hierarchy in data. Instead, each individual report and invoice has a list of users allowed to see that report.
[{
"OrderNumber": "12345",
"Users": [{
"UserCode": "A",
"UserDescription": "A"
},
{
"UserCode": "B",
"UserDescription": "B"
},
{ "UserCode": "C", "UserDescription": "C" }, { "UserCode": "D", "UserDescription": "D" }]
}]
Again, the data for reports and invoices does not capture the exact hierarchy in the same parent/child relationship as Options. Each report and invoice needs to explicitly list the users that are allowed to view the report or invoice.