Set custom field ReadOnly if Sub-tasks are present with Parent issue in Jira data center

Digvijay Singh Gehlot
Contributor
September 6, 2024

Hi Community,

I have created a custom Checkbox field present on Parent issue in Jira data center.

I want to set this Checkbox field in ReadyOnly mode, if Sub-tasks are created and linked to Parent issue on a particular status.

If there are no such Sub-tasks created/ linked with the Parent issue on a particular status, then the Checkbox field should be Editable.

Please guide on how we can configure the above use-case using scriptrunner, jira automation, or jmwe app.

Thanks

1 answer

1 accepted

2 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 6, 2024

Hi @Digvijay Singh Gehlot

Your requirement is pretty straightforward. You will need to create a Server-Side Behaviour for the checkbox field and set the condition to is so it will read-only if the field contains sub-tasks.

Please refer to this code snippet for a working sample code.

Below is the code from the code snippet for your reference:-

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScriptFieldBehaviours behaviours
def sampleCheckbox = getFieldById(fieldChanged)
sampleCheckbox.readOnly = false

if (underlyingIssue.subTaskObjects.size() > 0) {
sampleCheckbox.readOnly = true
}

Below is a screenshot of the Server-Side Behaviour configuration:-

behaviour_config.png

I hope this helps to solve your question. :-)

Thank you and Kind regards,
Ram

 

Suggest an answer

Log in or Sign up to answer