Hola Atlassians,
I have seen several cases of adding a postfunction and/or using ScriptRunner to add a comment automatically after doing a transition, but my case scenario is different.
I have a workflow transition "Rejected", which moves a ticket's status to "Rejected"
That transition screen has 2 fields - a "Rejection reason", and a "comment"
Depending on the "Rejection reason", I want to populate the comment with a pre-defined template,
AND I want to show an error if the comment was not edited (i.e. comment === comment_template)
Example:
Rejection reason: Not reproducible
Comment template:"""
Status: Failed
Error: Unable to reproduce the error.
Tested on version: {{VERSION}}
"""
and if the final comment matches the Comment Template, user shouldn't be able to go through the transition, and actually show an error "Comment not edited".
I would appreciate your support on that, hoping to find a proper solution for this problem.
Thank you!
Answer on the issue:
ScriptRunner's Behavior is definitely the correct way to handle it, but it wasnt working properly as I was using JEditor on Jira, rather than the default text editor for comments.
After reaching out to JEditor's support team, they suggested I add the following CSS code in the JEditor Custom CSS section, and then I could use ScriptRunner Behavior properly:
/* JEditor support - ticket #3576 */
.wiki-edit.jeditor-original-container {
display: block !important;
visibility: hidden;
position: fixed;
}
Hope this helps others!
My suggestion would be a simple one:
On your "Reject" transition screen, just put 2 fields "Rejection reason" and "Tested on version"(do not put comment field here).
Once this is submitted, we can run an automation which will drop a dynamic comment on the ticket based on the values of these two fields.
Thanks,
Aditya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @patman_y ,
I reached the community page through the advertisement you opened. I examined your request, it can be done with Behavior, but it will not be enough alone. Scripted Validator will also be required. Only then can the transition be allowed by checking whether the comment has been edited or not.
If you would like to get professional support on this issue, please be clear in the comment and I can refer to your ad.
Best regards, Yavuz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This would be possible in behaviours in scriptrunner. Pseduocode that should achieve your use case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hey @Michael Bramhall
here's my code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager
// Get the value of the rejection reason field
def rejectionReasonField = getFieldById(getFieldChanged())
def rejectionReason = rejectionReasonField.getValue() as String
// Prepare the template based on the rejection reason
def commentTemplate = "DEFAULT VALUE"
switch (rejectionReason) {
case "Reason 1":
commentTemplate = """
Status: Rejected
Reason: Lorem ipsum 1
""".trim()
break
case "Reason 2":
commentTemplate = """
Status: Rejected
Reason: Lorem ipsum 2
""".trim()
break
default:
commentTemplate = "No specific reason provided."
}
// Set the Comment field value with the template
def commentField = getFieldById("comment")
commentField.setFormValue(commentTemplate)
and yet, the commentField doesnt get modified at all, even with the DEFAULT VALUE.
Am I doing something wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @patman_y
Welcome to the community!
Regrettably, this is not achievable using the native Jira tools.
You may be able to archive this with the Behaviours - ScriptRunner for Jira Cloud app.
Best regards
Sam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Samuel Gatica _ServiceRocket_ ! thank you for your reply
How would this be done with ScriptRunner Behaviours? I tried ChatGPT'ing it, but to no avail, unfortunately
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.