Show pending Approval Items for running User or any Groups that the user is a part of

I am trying to show pending Approval Items for the running User, but in Salesforce, Approvals can be assigned to a User or to a Group that the user is a member of.

To make it more complex, Groups can be members of other Groups, so, say that the Approval Item is assigned to East Coast Sales, which has child Groups, Southeast Sales and Northeast Sales, and the User is a member of Southeast Sales, then this Approval Item should show up as well.

Or if the Approval is for a Group that the User is a member of via the User’s Role (since Roles can be members of Groups), this should show up as well.

I tried using a “Result of Subquery” Condition with Subcondition Logic that includes OR statements, such as “1 OR 2 OR 3 OR 4”, but OR logic is not allowed on Semi-Join Subselect queries.

Can this be set up using Skuid Models?

This can be done by querying separately for the User’s Groups, the User’s Role Groups, the Groups that the User’s Groups are a member of, and the Groups that the User’s Role Groups are a member of — and then using 4 “Field from another Model” IN Conditions on your Approval Items (ProcessInstanceStep) combined with OR Condition Logic.

Here is a Gist containing the XML for a starter Skuid page that will enable this.

Here is a screenshot of the Conditions for each of the 5 Models required:


Hi Zach,
I copied in this XML and when I tested I was seeing more Pending Approval records than I had in my standard Home Page “Items to Approve”.  What I saw was that this list showed items that were pending approval that I had submitted but that were not pending my approval.  Was that the intention?  I would only want to see the items that logged in User needed to approve.

Bridget, I think that the intention was to show items that the logged in User needed to approve, or items that need to be approved by a member of a Group or Role that the User is a part of / assigned to.  My understanding of the ProcessInstanceStep object, coming from the API doc, is that the “ActorId” field describes exactly what you’re looking for — the User who is currently needing to approve an item. I may be missing something here, but from what I can tell, the Model setup described above should be doing what you’re after, but it may contain some extra data in the case that there are Approvals assigned to Public Groups or Roles that you’re a part of.

Thanks for the response Zach.  How could I skinny it down to just be the records that were pending the logged in Users approval?

If that’s all you’re after, you can probably delete the first 4 Models, and on the PendingApprovalItems Model, do the following:

1. remove the Condition Logic
2. Remove Conditions 3-6, so that only the following are left:

1. ProcessInstance.Status = “Pending”
2. ActorId = (Userinfo) User Id