Script Runner - Make Comment Field required on Issue asign

When users asign issues to each other via the standard asign-function in JIRA (not via workflow transition) I'd like the commentary field to be mandatory. Is that possible in any way?

2 answers

2 accepted

4 votes
Mahesh S Community Champion Dec 01, 2016

Yes, Johny's script might help you. In addition to that, you can remove Assignee field from edit screen and hence, it will be available only in Assign screen. Otherwise, the user can cheat you by performing an inline edit of Assignee in the view screen itself.

Actually, if you have a behaviour associated with a field, it should disable inline editing on the View Issue page. Granted, the user could still cheat with more advanced techniques; disabling inline editing is JavaScript based, and happens shortly after page load. Behaviours are about convenience, not security.

Tarun Sapra Community Champion Dec 07, 2016

Good to know -  if you have a behaviour associated with a field, it should disable inline editing on the View Issue page

Mahesh S Community Champion Dec 07, 2016

Yes.. Good to know! smile

You bet it is! This can be done with a Behaviour. Create a behaviour on the Assignee field with a validation script like the one below:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def commentField = getFieldById("comment")
def assignee = getFieldById(getFieldChanged())

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
log.debug("Assignee: $assignee.value ; Current User: $currentUser.name")

boolean requireComment = assignee.value != currentUser.name && underlyingIssue.getAssignee().name != assignee.value && assignee.value
log.debug("Comment required: $requireComment")
commentField.setRequired(requireComment)

That will make the comment field required whenever the assignee is not "unassigned" and it's not the same user as the person doing the assignment. It should work on the edit issue and assign issue screens.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

93 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you