Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to make comment field required during the edit

Omprakash Thamsetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 27, 2021

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. 

1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
October 28, 2021

Hi @Omprakash Thamsetty

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:-

behaviour_config.png

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:-

image1.png

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:-

image2.png

image3.png

I hope this helps to answer your question. :)

 

Thank you and Kind Regards,

Ram

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.4
TAGS
AUG Leaders

Atlassian Community Events