How to prevent problem transfer in postfunction
Hello, my current jira environment uses the ScriptRunner plugin, and I have such a request.
I want to add a custom script fragment to the post function of the workflow, when something does not conform to the flow, throw an exception and prevent the problem state from changing.
What should I do please?
You do not do this in a post-function. Post-functions run at the end of a transition, after you've decided you're going to commit to it, it is too late to change your mind about doing it. Imagine you're going sky-diving - a post-function would be "open parachute" as you're on your way down, not "decide not to jump".
You need a validator - these check the data the user enters into the transition screen, and the current data on the issue and returns the user to the transition screen if the data fails your checks. (You might also look at a condition - these stop people from clicking on a transition if the data doesn't match your rules)
There are some examples of validators at https://library.adaptavist.com/search?page=1&products=jira&term=validator