Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner/Groovy Cannot invoke method getSprintsForView() on null object

ludwigbayer
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 1, 2018

I'm attempting to use a ScriptRunner/Groovy script to give me a list of active and open (in progress & future) sprints in a specific board. For some reason, whenever I use the getSprintsForView() method, it fails and errors "cannot invoke method getSprintsForView() on null object".

The odd thing is that I check if the view is null, and the view seems to work just fine with other methods (like getOpenSprintsAndBacklogProjects. 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.greenhopper.service.rapid.view.RapidViewService;
import com.atlassian.greenhopper.service.rapid.RapidViewQueryService;
import com.atlassian.greenhopper.model.rapid.RapidView;

import com.atlassian.greenhopper.service.sprint.Sprint;
import com.atlassian.greenhopper.service.sprint.SprintManager;

def sprintManager = ComponentAccessor.getOSGiComponentInstanceOfType(SprintManager.class);
def rapidViewService = ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewService.class);
def rapidViewQueryService = ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewQueryService.class);

board_id = 89L;

def sprints = [];
def sprints_two = [];


def view = rapidViewService.getRapidView(user, board_id).getValue();

if (view != null)
{
sprints = rapidViewQueryService.getOpenSprintsAndBacklogProjects(user, view).getValue().left();
sprints_two = sprintManager.getSprintsForView(view).getValue();
}

 

What am I doing wrong?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Vikrant Yadav
Community Champion
August 5, 2021

Hi @Sidney Ambrose  Welcome to Atlassian Community!

Kindly use the method suggested in this link :- https://mraddon.blog/2018/02/25/how-to-set-a-default-description-template-in-your-jira-tickets/amp/

 

Hope it works for you!

Thanks

V.Y

Vikrant Yadav
Community Champion
August 5, 2021
Sidney Ambrose
August 5, 2021

Hi Vikrant,

Thank you so much for the assistance. It worked when we had the script in initializer.

Regards,
Sidney

Vikrant Yadav
Community Champion
August 6, 2021

Great, Glad to hear it works for you :)

Kindly accept the solution, if solution works for you so that it helps others users having same query. 

Thanks

V.Y

Charlie
March 17, 2022

Hello @Vikrant Yadav , the method suggested also works for jira cloud ?

https://mraddon.blog/2018/02/25/how-to-set-a-default-description-template-in-your-jira-tickets/amp/

Thank for your help.

C.T.

Vikrant Yadav
Community Champion
March 18, 2022

Hi @Charlie  This method is for JIRA Server and JIRA DC version. For JIRA Cloud, this doesn't work. 

For jira colud, you can create Custom field and set Default value of that field. 

 

Thanks

Vikrant Yadav

TAGS
AUG Leaders

Atlassian Community Events