When you click submit to a request that needs approval, one big question is who approved my request? The final decision I can see if I scroll down on the request. It is not a big deal if I know that there is only one approver like it will always go to my manager, but what about if it goes to 3 or 10 people for approval? When one of then acts on the request that closes the request, but who acted? Its very important for audit reasons as well. The information is in MIM but it is buried a bit deep, so lets dig it out.
Where is this information?
A request object instance which requires an Approval spawns an Approval object instance, when one approves, an ApprovalResponse object instance is spawned. The ApprovalResponse has who acted on the request it and status (Approved/Rejected). All these objects are joined relationally.
So we have to dereference from the ApprovalResponse back to the Request.
Solution
Note something here: Suppose your request has multi layered approvals? It means there will be several approval objects associated with that request, in such a case which approval will you write to the request? In such a case I would say you may have to creative. There are somethings you can do, but for the purpose of this blog, I will assume its single layer approval.
Create 3 Attributes
- ApprovalCompletedBy
- ApprovalStatus
- ApprovalReason
Bind all 3 attributes to the Request object
Create a Set “All ApprovalResponse” with criteria /ApprovalResponse
Create a Workflow with the following [Using MIM WAL]
Activity1: Do a Query to get the Approval associated with the ApprovalResponse with this Xpath /Approval[ObjectID=/ApprovalResponse[ObjectID='[//Target]’]/Approval]
Store the result in [//WorkflowData/MyApproval]
Activity2: Do a query to get the Request associated with the approval
/Request[ObjectID=/Approval[ObjectID='[//WorkflowData/MyApproval]’]/Request]
Write to your Query result
[//Target/Creator] => [//Queries/MyRequest/ApprovalCompletedBy]
[//Target/Decision] => [//Queries/MyRequest/ApprovalStatus]
[//Target/Reason] => [//Queries/MyRequest/ApprovalReason]
Create a Transition-In MPR to fire the workflow with the Target set All ApprovalResponse
Edit the Request RCDC and add these 3 attributes
Update MPR: Add these 3 attributes to the MPR that allows a user to read requests