Hello, while in Jira Cloud, using Scriptrunner, I am trying to add a validator that will make the comment field mandatory on a transition, if the resolution is set to "Cannot Reproduce".
I am trying to use conditional-expressions, but I haven't been able to find the proper way for it:
issue.resolution == 'Cannot Reproduce' ? issue.comments.length > 0
Please let me know how this would need to be written.
Thank you!
Hi arama, I don't think you will need to use conditional-expression in this case. Base on your condition I think you can do it like such :
issue.resolution?.name != "Cannot Reproduce" || (issue.resolution?.name == "Cannot Reproduce" && issue.comments.length>0)
This will return true if you set the resolution to other than "Cannot Reproduce"(Done e.g) OR it will return true when resolution is set to "Cannot Reproduce" and contains comment to it.
Based on your original condition seems like you did not refer to the resolution correctly.
You can checkout the Jira Expression Type in this documentation too: https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference/#resolution
Try it out and see whether this fix your issue
Hello @Khairul Danial ,
Thank you for your reply. Your validator works almost as expected. But there is one major factor to be taken into consideration. It checks for comments entered on the issue at any moment (prior to the transition), but I would need it to prevent the transition if the resolution is "Cannot Reproduce" and a comment is not entered in the current transition screen.
Please let me know if you think that is possible.
FYI, on server it was:
issue.resolution?.name != 'Cannot Reproduce' || transientVars["comment"]
Best regards,
Mihai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
issue.resolution?.name != "Cannot Reproduce" || (issue.resolution?.name == "Cannot Reproduce" && issue.comments.filter(comment => comment.id == null).length ==1)
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.