[SalesForce] Display “Submit for Approval” button in the Approval History related list based on condition

I have two custom objects with master detail relationship.

My requirement is that the parent should be submitted for approval only after all its child records are submitted for approval.

For this, client has asked me to show the "Submit for approval" button in the Approval History related list only the above condition is satisfied.

I think the solution can be achieved through VF page by removing the "Submit for approval" button from the Approval History related list and showing it using the condition.

But my question is:- Is it possible to remove the "Submit for Approval" button from the Approval History related list?

Also, I should not hide the Approval history section(as a way to prevent the users from submitting for approval when criteria is not met) because users should be able to see the approval history.

Best Answer

You can't customise the buttons on the approval related list like you can for the others.

Aside from Visualforce, you might want to take a look at this post from Jason Venable (aka TehNrd) regarding showing/hiding buttons through javascript:

http://www.tehnrd.com/show-and-hide-buttons-on-page-layouts/

You could then have a roll up summary field on your master record that shows the number of child records that have not been submitted for approval, and your javascript can interrogate that value and hide the button accordingly.

There is an element of fragility about this, as you'd be relying on accessing fields/buttons by names that could conceivably change under you.

Another way to approach it may be to have the approval process entry criteria take into account the rollup summary field of child records not submitted for approval. While that wouldn't stop the button being displayed, it would stop the record entering the approval process.