Hi,
I used behavior to make comment field required with following code but it is required during the assign also.
def orgEstDEV = getFieldById(getFieldChanged())
def orgEstDEV_Val = orgEstDEV.getValue()
if((getActionName() != "Create") ){
def underlyingOrgEstDEVVal = underlyingIssue?.getCustomFieldValue(orgEstDEVDetails) as Long
def commentField = getFieldById("comment")
if( underlyingOrgEstDEVVal != orgEstDEV_Val){
if(commentField) {
commentField.setRequired(true)
}
}else{
commentField.setRequired(false)
}
}
On create underlying issue value will not be there so I written the condition not to execute for on create.
I am getting null for getActionName() for Assign so the condition is true then making comment field required.
How I can make comment field required when Original DEV (number) custom field change?
Any help is much appreciated.
For your requirement, you could try something like this:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def comment = getFieldById('comment')
comment.required = false
// modify the actionName condition according to the transition screen name used
if(underlyingIssue && actionName != 'In Progress') {
comment.required = true
}
Please note, the working sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
You will need to use the Initiliser instead of the Server-Side Behaviour.
Below is a print screen of the Behaviour configuration:-
Below are a few test print screens for your reference:-
1) When I try to edit an existing issue, the Comment field is set to required as shown in the image below:-
2) If I try to transition my issue to In Progress, in which I have added a transition screen with the name In Progress, the Comment field is not set to required as shown in the Images below:-
I hope this helps to answer your question. :)
Thank you and Kind Regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.