How to retrieve Sprint value of an issue using script?

 

4 answers

This widget could not be displayed.

On the current issue you need to iterate over all custom fields and check if there is the custom fiel of type: "com.pyxis.greenhopper.jira:gh-sprint".

If that customfield exists, you need to do something like this:

CustomField customField
Issue issue....
...
Object cfValue = customField.getValue(issue);
final List sprintList = (List) cfValue;
                // Get the first one
                if (sprintList != null && sprintList.size() > 0) {
                    final Method ghSprintMethod = printList.get(0).getClass().getMethod("getName", null);
                    final Object resultValue = ghSprintMethod.invoke(sprintList.get(0), null);
                    if (resultValue instanceof String) {
                        cfValue = (String) resultValue;
                    }
                }

 

I hope this helps you.

Cheers,

RMRodrigues.

Hi Rui thanks for the answer. i need to make a custom field read only depending on this sprint value. any idea to how to achieve this?..

Your custom field was created by a plugin or from Administratin->Issues-> custom fields?

I have created it by administrator options not by a plugin.

OK. I don't know if it's possible via configuration. Maybe you need to install a plugin that allows you to do that. Cheers, RMRodrigues.

Yes Rui I tried with Behaviours plugin using above code i posted. the problem is my code works fine with other custom fields and no result with using the Sprint field. it seems my code unable to read the value of the Sprint. anyway thanks for your valuable time consumed.probably i need to see this thing in different angle. Cheers..:)

Add a tag of that plugin on your question in order to get more help. "addon-com.onresolve.jira.plugin.behaviours"

This widget could not be displayed.

Hi, Are you talking about getting the sprint name from Java code?

This widget could not be displayed.

Hi Rui yes,I just want to check the sprint field null or not i have used Behaviours plugin and tried following script FormField sprint = getFieldByName("Sprint") FormField productArea = getFieldByName("Product Area") String sprintValue = (String) sprint.getValue() if(sprintValue!= null){ productArea.setReadOnly(true) } but not able to get any result.

This widget could not be displayed.

i just wanted to check this sprint field and if its not null then make one custom field read only.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

55 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you