I have been asked to add a post-function that adds a comment to an issue on a transition if a particular field is empty. I cannot find any way to do this at all.
I tried to use the code below but this failed with a 'cannot find matching method' error. In any case, even if I wanted to use scriptrunner, the only way I can see to use this is to use a custom script post-function, which lacks the conditional section.
I have been searching high and low for an answer but to no avail. The solution does not need to be scriptrunner, though the only other option I have is JSU and I don't see a way of doing it there.
CODE:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.comments.CommentManager
ComponentManager componentManager = ComponentManager.getInstance()
CommentManager commentManager = componentManager.getCommentManager()
commentManager.create(issue, transientVars.context.caller, "Comment automatically generated...", false)
Hi @Rob Horan
with JSU it's super easy to achieve this by combining these two modules:
Fields Required Precondition
Update any Issue Field Post-Function
It will take you less than a minute to configure this. No scripting at all :-)
And you have a solid proven solution without any maintenance hassle.
You can read more about JSU's Preconditions for Post Functions here:
Workflow Preconditions
The completed configuration will look like this:
Hi @Rob Horan
I would notspend too much time trying to script this...
You could use the excellent automation lite (free plugin) that has if/else blocks and can achieve what you need pretty easily; OR alternatively you could do this, since you have JSU.
1. use the condition "Field Value" from JSU in the "normal" transition and allow it only if the value is in the field (you will use "different to empty")
2. create a second transition between the two statuses; it can have the same name of course; for this you will set the condition that the value is empty (equal to empty).
3. In this second transition, you add the comment with the scriptrunner post function for adding a comment.
I hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.