문제

The problem that I'm trying to workaround is that we cannot report on pending approvals.

I've seen the recommendation that we update fields on the object that is being routed in the action that executes after each step - however this doesn't work when the step is for parallel approvals.

I haven't been able to find an object I can attach a trigger to that would fire after each person approves.

At the end of the day I need to be able to product a report of who needs to approve what (I am aware that each person will see what they need to approve on their homepage, I need others to be able to pull a report on all the pending approvals).

Any ideas?

도움이 되었습니까?

해결책

Since I really needed for anyone to be able to check all pending approvals or pending approvals for a particular users at any given time I created a VisualForce page and used the below queries depending on looking for every pending approval or ones for a user.

For all pending approvals:

[SELECT Status, TargetObject.Name, TargetObjectId, TargetObject.Type, (SELECT Actor.Id, Actor.Name, Actor.Email, CreatedDate FROM WorkItems)
                                    FROM ProcessInstance
                                    WHERE TargetObject.Type = 'ObjectICareAbout__c' and Status='Pending']

For pending approvals for a given user:

[SELECT ActorId, Actor.Name, Actor.Email, CreatedDate, ProcessInstance.Status, ProcessInstance.TargetObjectId, ProcessInstance.TargetObject.Name
                                            FROM ProcessInstanceWorkitem
                                            WHERE ActorId = :user AND ProcessInstance.Status = 'Pending' AND ProcessInstance.TargetObject.Type = 'ObjectICareAbout__c']

These are then mapped to a common view model to displayed in the VF page.

다른 팁

First and foremost - go to Reports -> Administrative Reports -> All pending approval requests.

Check it out and see if it can be fine-tuned to match your needs. If you need to be able to share it with non-admins - consider making a dashboard out of it (can be Table) and schedule it for daily run & email sending...

If you feel you still need a workaround - we can certainly experiment with

however this doesn't work when the step is for parallel approvals

Have you tried using formulas in the update? Stuff like someHiddenNumberField +1 might work (I can't test it in my Dev edition at the moment); if not directly like that then with some syntactic sugar like PRIORVALUE(). Or maybe even better - having a text field and appending in it date/time + who approved. Then in last step you clear the "counter" and are done.

If trick with formula-based updates will not work (no promises, it's just an idea) then maybe keep the old way of setting special field but define also a "before update" trigger on this object (or workflow? but that's again a formula) that will check value, update "counter" and set the hidden field back to original value.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top