Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to read Issuetype field from script runner

Dear all,

I am using Script runner under Jira Cloud on which I need to convert Script Runner Script from our server side .

From our initial script we are checking different field like:

  • issue IssueType
  • issue assignee
  • issue assignee DisplayName :


Actually I am retrieving for instance the information as below :

// Fetch the issue object from the key
def issue = get("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.asObject(Map)
.body

// Get all the fields from the issue as a Map
def fields = issue.fields as Map
def issueType=fields.issuetype as Map

def project= fields.project as Map
return project.key

Based on code snipet above, I am succesfully returning the project key

But I am not able to get the issueType name, any idea how to get it correcttly?

regards

serge

 

2 answers

1 accepted

1 vote
Answer accepted

Hello @Hana Kučerová , I manage to get it the follwoing way only

def issue = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)

def IssueType= issue.body.fields.issuetype.name

Hi @serge calderara ,

please try:

fields.issuetype.name

or using your variable

issueType.name

hello @Hana Kučerová , I have tried and received the following exception

// Get all the fields from the issue as a Map
def fields = issue.fields as Map
return fields.issuetype.name

MissingPropertyException: No such property: fields for class: io.github.openunirest.http.HttpResponse

Any idea ?

Hello @Hana Kučerová , I manage to get it the follwoing way only

def issue = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)

def IssueType= issue.body.fields.issuetype.name

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you