Restrict Approval of Case Once Closed - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Toni Lynn MangoneToni Lynn Mangone 

Restrict Approval of Case Once Closed

I have an approval process, which requires that specific cases are approved by the Creator's Manager before they are actioned by our Sys Admin team.  However, if the Manager takes too long to approve the request, we have a Workflow Rule that automatically closes the case.  This ensures that we don't have aged cases out there, just waiting for a Manager's approval.

The issue is that even after I close a case using the Workflow, a Manager is able to go back in via the Approval History (or their Home Page) and click the Approve/Reject button and Approve the case.  I have tried writing a Validation Rule that will restrict editing the Case once closed ... but this rule doesn't seem to fire if the Approval Process edits the case.

Is there anything that I can do, to ensure that once a case is closed, a Manager can NOT go in and approve (or reject) the case, thus "reopening" it?

Thanks!
Medardo NavaMedardo Nava
Hi Toni,

I dont think there is anything you can do to prevent this scenario to happen -  as the approval process is kind of agnostic of the current state of the record - it only cares on the state of the record once is triggered to see the criteria is met. 

I would suggest you to use the standard report so you can see which approval processes are outstanding and then manually close them. 

Go to the Reports Tab > Click on the Administrative Reports Folder > All Pending Approval Requests report.

There is no ID available for the approval record so I dont think you can mass update them via data loader.

Best,
Medardo.



Medardo NavaMedardo Nava
Toni,

If there are a lot of records to update and this becomes in a time consuming task - you could set a filed update to re-activate the case once is approved.

Cheers!
Shivanath DevinarayananShivanath Devinarayanan
you can restrict the submit for approval with an entry criteria. 

You can vote for the idea though 
if our suggestion(s) worked,  let us know by marking the answer as "Best Answer" right under the comment.This will help the rest of the community should they have a similar issue in the future.  Thank you!

Shivanath
Jim RaeJim Rae
Toni,
You could leverage record types, add a second record type for a closed case that has it's own Page Layout. In the Closed Case Layout, removed the approval history related list, which would prevent the manager from approving.

If you find this response helpful, let the community know by marking the answer as "Best Answer" right under the comment.This will help the rest of the community should they have a similar issue in the future.  Thank you!
Toni Lynn MangoneToni Lynn Mangone
@Jim Rae --- That's the best idea so far ... however, although I can remove the Approval History from the Page Layout, it still exists on our User's Home page.   I don't think I could get approval to remove it from the Home screen, because that would make active approvals very hard to find for most users.

Any other ideas?
Medardo NavaMedardo Nava
Hi Toni,

If you want to go @Jim's route you could create a trigger that fires after update and get this trigger to query the approval process associated to the record and reject it. I know you can submit for approval using a trigger but I am not sure if you can query a pending approval process associated to a record and then manipulate it (acepting it or closing it).

Here are some links that may help you:

Triggers and order of execution > http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm

Apex approval process > http://forums.sforce.com/t5/forums/forumtopicprintpage/board-id/apex/message-id/127463/print-single-message/false/page/1

Another avenue to review is to see if you can get access to the approvalobject via data loader and perform mass updates via that way -- The report in salesforce that shows you the pending approval processes does not expose an Id so it seems like not.

So overall you you can flip the RT via a time based WFR, in the layout of the new RT remove the approval history section and then make the WFR fire a trigger (if possible) that queries the approval proccess associated to the record and then rejects it - so the approval is removed from the home page layout of the approvers.


Toni Lynn MangoneToni Lynn Mangone
Thanks, @Medardo ... I think what we've decided is to write a trigger similar to what you've suggested.  Based loosely on this post --> http://boards.developerforce.com/t5/Apex-Code-Development/Recalling-Approval-Process/td-p/115499, it will actually query the Approval Processes on ANY Case that is closed (on closure), and if there is a pending Approval Process on that case, it will recall the approval. 


That way, we won't need to flip the RT or create new WFR ... just a single trigger should do the trick.  When it's built, I will post the code in case anyone else has issues.
Jim RaeJim Rae
Well, for one of my clients I actually rewrote the Approval Component on the home page as a custom VF page (in my case it was due to the client needing to see some additional fields, but you could set it up so the aged approval requests no longer appeared, or were somehow indicated as "Expiring" (as a way to motivate them to be approved in a more timely manner).