We need to make a dashboard displaying below two values
Epic Name No of stories/tasks created under Epic
Please help us to count the stories/tasks. We have scriptrunner for Jira Cloud. I'm a neophyte with Scriptrunner. I read that a scripted field might be a good answer. This was recommended on another question however it's not working for me.
Please help!
Hi @CC
From the script that you have shared, it appears that you are trying to use the Jira Server / DC API in the Jira Cloud via ScriptRunner.
This will not work.
If you intend to initialise any object, it must be done via REST requests.
In the editor that you are using, if you click on the sample codes provided, it will show you how to make the REST Requests.
I will try to prepare a sample for this.
Thank you and Kind regards,
Ram
@Ram Kumar Aravindakshan _Adaptavist_ Any chance you can prepare a sample? I'm not that advanced in REST.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @CC
Sorry for the late reply. I've been a bit busy and didn't have time to play around with this.
Below is the sample working Cloud script for your reference:-
def issueKey = 'MOCK-1' //Change the Epic Key according to your environment def jql = "rest/api/2/search?jql='Epic Link'=${issueKey}"
def filteredJql = jql.replace(" ","%20").replace('"',"%22") def body = get(filteredJql).asObject(Map).body def issuesInEpic = body['issues']['key'] def storyPoints = [] as List<Double> issuesInEpic.findAll { def childIssue = get("/rest/api/2/issue/${it}").header('Content-Type', 'application/json').asObject(Map) def issueType = childIssue.body.fields['issuetype']['name'] if (issueType in ['Story', 'Task']) {
//Change the custom field id according to your Cloud instance
storyPoints << Double.parseDouble(childIssue.body.fields['customfield_10018'] as String) } } storyPoints.sum()
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
If you observe the example above, I need to make a couple of GET requests and filter out the details accordingly.
Also note that in my Cloud instance, the id for the Story Points field is customfield_10018. You will need to modify this according to your instance.
You can run this on the ScriptRunner console to get the result.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
cool. Thank you so much. I'll give it a go in a few.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @CC ,
Has your question been answered?
If yes, please accept the answer.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @CC,
I am Marlene from codefortynine.
Another option would be our app Dynamic Custom Fields for Jira.
With our app you can add a custom field to your issues, which displays the number of child issues under a parent issue (e.g. epic).
Our app is working with Jira expressions, but we offer a template for your use case. Therefore you don't have to be able to write the expression in order to create the field.
After installation you simply
The field can be used in JQL and your statistics as any other Jira number field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @CC
Not sure if this is what you are looking for or not, but I added an Issue Statistics gadget to the dashboard and used the project for the Project or Saved Filter and the Epic Link field for the Statistic Type. Give that a try and see if that is what you want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible Issue has to be wit a capital letter I ?
so :
import com.atlassian.jira.issue.Issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.