Now let’s assume that we want to approve each cost center being added or removed individually, e.g., by a manager of a given cost center.
(Another, perhaps more realistic, example is approving inducements added or removed from a role by their owners or approvers.)
The rules would look like this:
Rule |
Description |
1 |
Each modification of a user record should be approved by his line manager. |
2 |
Each modification of a user’s costCenter should be approved by his line manager and the manager of the cost center being added or removed. |
So, the behavior for typical scenarios would be:
Scenario |
Description |
Behavior |
1 |
User’s administrativeStatus is changed. |
One process is created, asking the line manager for his approval. |
2 |
User’s costCenter is changed: A single new value is added. |
One process is created, asking the line manager and the cost center manager for their approvals. |
3 |
User’s costCenter is changed: One value (CC1) is removed and two new values (CC2, CC3) are added. |
Three processes are created:
-
A removal of CC1: asking line manager and CC1 manager for their approvals.
-
An addition of CC2: Asking the line manager the and CC2 manager for their approvals.
-
An addition of CC3: Asking the line manager the and CC3 manager for their approvals.
|
3 |
User’s costCenter and administrativeStatus are changed.
The value of CC3 is removed and the value of CC4 is added. |
Three processes are created:
-
An approval to change administrativeStatus: the line manager is asked.
-
An approval to remove CC3: The line manager and the CC3 manager are asked.
-
An approval to add CC4: The line manager and the CC4 manager are asked,
|
As for the implementation, rule 1 is the same as in previous example.
Rule 2 is slightly modified:
Implementation of rule 2 (costCenter modification)
<globalPolicyRule>
<name>modification-of-cost-center</name>
<policyConstraints>
<modification>
<item>costCenter</item>
</modification>
</policyConstraints>
<policyActions>
<approval>
<processSpecification>
<deltaFrom>
<itemValue>costCenter</itemValue>
</deltaFrom>
<includeAction>line-manager-approval</includeAction>
</processSpecification>
<compositionStrategy>
<order>20</order>
</compositionStrategy>
<approverExpression> ... </approverExpression> <!-- deriving manager for the CC being added or removed -->
</approval>
</policyActions>
<focusSelector>
<type>UserType</type>
</focusSelector>
</globalPolicyRule>
<item>costCenter</item>
was changed to <itemValue>costCenter</itemValue>
, meaning that we are no more interested in the change of costCenter as such, but in each value of costCenter that is being added or deleted.
Also, the fixed approverRef
is replaced by approverExpression
.
Details of the expression are left as an exercise for the reader.