Hi Team,
How can I write a Groovy script(behaviours) that checks if the Epic Link value is equal to a certain value, and if so, makes specific fields visible while hiding the existing ones?
Please help.
Best Regards
Sakshi
Hi @Nema_ Sakshi I have tested below script on my DC instance, it works well.
import com.atlassian.jira.component.ComponentAccessorimport com.onresolve.jira.groovy.user.FieldBehavioursimport com.onresolve.jira.groovy.user.FormField// Get the current form fieldsdef epicLinkField = getFieldById(getFieldChanged()) // Epic Linkdef customFieldManager = ComponentAccessor.getCustomFieldManager()// Field keys to be shown or hiddendef fieldToShow = getFieldByName("Cost") // Replace with your field name to showdef fieldToHide = getFieldByName("Benefit") // Replace with your field name to hide// Get the current value of the Epic Link fielddef epicLinkValue = epicLinkField.getValue()// Define the target epic key for the conditiondef targetEpicKey = "KISHAN-07" // Replace with your Epic issue key// If the Epic Link value matches the target key, show specific fields and hide othersif (epicLinkValue == targetEpicKey) {// Show certain fieldsfieldToShow.setHidden(false)// Hide the other fieldsfieldToHide.setHidden(true)} else {// Default behavior: show or hide as per your requirementsfieldToShow.setHidden(false)fieldToHide.setHidden(false)}
In this example, its checking if the issue has KISHAN-07 as its EPIC Link, if yes, it hides Benefit field and shows Cost field, else, it shows both the fields. Hope this helps you to get started.
It looks like you're new here. Sign in or register to get started.