Validate comments using a custom script

s-v-z October 17, 2018

I need to perform some custom validation when a comment is added to an issue. I'm trying to use Scriptrunner bundle for that, but no luck so far. What I've tried is:

1. Add a Custom Listener that would perform validation on Issue Commented event. The problem here is that I can't stop the comment from being updated and return an error message if validation fails.

2. Add a Workflow Transition validator. The problem here is that it runs only when a transition is performed and adding a comment doesn't seem to trigger one.

3. Add a behaviours field for Comment, but it doesn't seem to do anything at all. I've tested this code and it doesn't work:

def commentField = getFieldByName("Comment")
commentField.setError("Error message for comment") 

 

So what is the right way to implement a custom validation when a Comment is added to an issue? 

0 answers

Suggest an answer

Log in or Sign up to answer