It's all about the answers!

Ask a question

How can a Work Item be prevented from being Closed if there are any pending Approvals?

Geoff Binns (30425) | asked Apr 20 '16, 4:45 a.m.

It is a specific use case and wondered if anyone has a specific solution.

We want to stop a Work Item from being Closed if there are any Approvals pending. The problem is that Approvers can still receive emails if Approvals are overdue even though the Work item is Closed.

If a Work Item has multiple workflow actions to a 'Closed' state is it possible to inhibit either the transitions or Work Item 'Save' if there are any Approvals pending.

Thanks for any help.

Accepted answer

permanent link
Ralph Schoon (63.2k33646) | answered Apr 20 '16, 4:52 a.m.
You have to write a custom advisor that checks this during the save and blocks the save. For an example see
The approval API: and

You would have to read the approvals from the new state and check if one is open.

See to get started.

Geoff Binns selected this answer as the correct answer

Geoff Binns commented Apr 22 '16, 9:13 a.m. | edited Apr 22 '16, 9:14 a.m.

Thanks for this Ralph. You've been a great help.

Looking through it seems very complex or tortuous to have to manage plug-ins, maybe install tools, learn JavaScript/Java, test on a separate instance.

Am I correct in thinking a certain amount of expertise is required or is it fairly straight forward?

Couldn't a simpler way of enabling the user to define pre and post conditions be provided?

Ralph Schoon commented Apr 22 '16, 10:03 a.m. | edited Apr 26 '16, 2:23 a.m.

Yes, as mentioned in it is torturous if you are new. I find it quite easy these days, but that took time.

No, there is no easier way to approach this, I would be aware of. I try my very best to provide you with what you need in my blog and give some background. You can also start with the extensions workshop but ultimately you want to see the other info as well.

One benefit I do see is that most of the users that finally decide to go that route are aware it can be complicated, usually have some skill and limit the effort to the absolutely necessary.

This prevents customizing the process to death to some extend.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.