Create a scripted field to count the number of open issues by reporter IN JIRA CLOUD
Asked by Alex LaMont:

So I am trying to do something similar to this post over here: [Scripted Field](https://community.atlassian.com/t5/App-Central-questions/Create-a-scripted-field-to-count-the-number-of-open-issues-by/qaq-p/1187970)  

The difference is, I am operating in Jira Cloud, where it appears that they are operating on Jira Server.  

When attempting to duplicate their answer I am getting an issue with the importer. (So of course I removed them, and with some help adapted the code to be as follows:  

```
import groovy.json.JsonSlurper

import groovy.json.JsonOutput

import groovyx.net.http.RESTClient




def jql = "project = PROJ and reporter = '${issue.reporter.name}' and statusCategory NOT IN (Done, Canceled, Closed)"

// Make the REST API call to Jira Cloud

def restClient = new RESTClient('https://OURSITEURL/rest/api/3')

def response = restClient.get(

    path: '/search',

    query: [jql: jql]

)

// Parse the JSON response and get the total number of issues

def jsonResponse = new JsonSlurper().parseText(response.data)

def totalIssues = jsonResponse.total

return totalIssues
```

```
?org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
 Script1.groovy: 3: unable to resolve class groovyx.net.http.RESTClient
  @ line 3, column 1.  
import groovyx.net.http.RESTClient  
^ 
  1 error 

  at com.adaptavist.sr.cloud.workflow.AbstractScript.parseScript(AbstractScript.groovy:50)
  at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:33)
  at com.adaptavist.sr.cloud.events.ScriptedFieldExecution.run(ScriptedFieldExecution.groovy:30)
  at TestScriptedFieldExecution1_groovyProxy.run(Unknown Source)
```

Apologies if this is a simple question, I am somewhat unfamiliar with API coding.


Answers:
author: Alex LaMont
body: We are doing this a different way using asset fields.  

The assets have "Linked issues" with a filter scope \~ Insight Object schema: YOUROBJECTSCHEMA Filter scope (IQL): objectType IN ("Person")  

\*Person obviously being the object for user.  

Inside object details is a list of all "linked issues" to that object. Essentially giving us the same data.  

![Asset Link.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/325721i15A0DCE363C65814/image-size/large?v=v2&px=999 "Asset Link.PNG")

comments: author: Joseph Chung Yin
body: [@Alex LaMont](/t5/user/viewprofilepage/user-id/3331489) -

I believe the only drawback your above solution is that, the link information is only visible within Assets UI. It is not visible when you viewing the Jira issues via issue view UI.

Glad you found a solution for your own ask.

Best, Joseph


author: Joseph Chung Yin
body: [@Alex LaMont](/t5/user/viewprofilepage/user-id/3331489) -

Welcome to the community. Scriptrunner for Jira is available for the CLOUD env. However, typically one creates scripted field for issue type, and the field is then show-up in the issue itself.

So when you stated that your field is to show the # of open issues reported by each reporter. what are you trying to do with this field. Because, I am not seeing the reasoning to have a scripted field to be displayed in the issue's UI.

Please advise, then we can better assist you.

Best, Joseph Chung Yin

Jira/JSM Functional Lead, Global Technology Applications Team

Viasat Inc.

comments: author: Alex LaMont
body: Of Course!  

We have a section in our JSM tickets that show information about the person reporting the issue that attaches to our Assets and various other things. We call this our "reporter details section". This way, an agent can find any relevant information across tickets, applications and hardware.  

The new request we are being asked for, is the we want the "Reporter Details" section to show a number of all current tickets related to that user to help identify larger, ongoing issues.  

Does that help/make sense?


Tags: cloud

jira-service-management

jira-service-management-cloud