Help me with the Code

CHINNAMUTHEVISAI_SATYANARAYANASHARMA February 27, 2024

Team,

i have two fields called acceptance criteria and story acceptance criteria both are text fields. I need to add behavior in script runner that when i enter some value in acceptance criteria then only story acceptance criteria should be enabled while creating issue in Jira cloud.

i wrote below code.

 

{
def acceptanceCriteriaField = getFieldByName("Acceptance Criteria")
def storyAcceptanceCriteriaField = getFieldByName("Story Acceptance Criteria")

def acceptanceCriteriaValue = Acceptance CriteriaField.getValue()

if (acceptanceCriteriaValue) {
    storyAcceptanceCriteriaField.setHidden(false) // Enable the field
} else {
    Story Acceptance CriteriaField.setHidden(true) // Disable the field
}
}
But its not working at the moment. I'm new to coding so please help.

1 answer

0 votes
Kristian Walker _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.
February 28, 2024

Hi,

In the cloud, you must reference custom fields by their ID and not names, so you will need to reference these fields using the getFieldById Method.

Also, then you can refer to the example we have here, which shows how to apply an action to a field when a value is changed.

You will be able to use this as a reference guide to help create the script that you require, ensuring you check when the acceptanceCriteriaField is not empty and then if so enable the storyAcceptanceCriteriaField.

If you still need further assistance with this script, can I please ask you to raise this issue as a support ticket here so that our support team can help investigate this and help you with writing the script.

I hope this information helps.

Regards,

Kristian

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events