Help me with a Groovy script in Jira cloud?

Team,

We have a fields called Notify with values Yes and No and Whom to Notify(User picker)
When i select Yes then only i can enter whom to Notify field. otherwise i should not enter value there.

i know we can do this through Behaviors, but I'm not good in Scripting.

if anyone have Script for this, please send i will made changes according to requirement.

1 answer

1 vote
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.
March 5, 2024

Hi Chinnamuthevisai,

 

You can achieve this requirement using the Behaviours feature of ScriptRunner for Jira Cloud.

We have an example script here that shows how to make fields required when a value is selected in a select list field.

You will be able to modify this to make the field read-only always and only editable when the value is selected in your Notify field.

Regards,

Kristian

Hi Christian,

Thanks for the code.

can you help me here?

I have two fields called Acceptance criteria and story acceptance criteria. both are multi line Text fields.

i want to try in sandbox that when acceptance criteria is Must have value in text then story acceptance criteria should be required. i modified the code as per that.

 

const changedField = getAcceptanceCriteria();

const isRequired = changedField.getType() == "com.atlassian.jira.plugin.system.customfieldtypes:Paragraph"
    //&& changedField.getName() == "Ticket Priority"
    && changedField.getValue().value == "Must have";

getFieldById("customfield_12382").setRequired(isRequired);
custom field id 12382 is for story acceptance criteria. its not working. can you please help?
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.
March 6, 2024

Can you try changing the field type from com.atlassian.jira.plugin.system.customfieldtypes:Paragraph to com.atlassian.jira.plugin.system.customfieldtypes:textarea to see if that resolves the issue.

Regards,

Kristian

still same issue.
I'm able to create issue when acceptance criteria field value is Must have and story acceptance criteria is not becoming required

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.
March 7, 2024

Hi Chinnamuthevisai,

To get help debugging this script further, I would advise you to create a support ticket here for our support team.

Regards,

Kristian

Suggest an answer

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

Atlassian Community Events