Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,352
Community Members
 
Community Events
184
Community Groups

How do I create a scripted field with scriptrunner in Jira cloud?

I've been beating my head against this wall and lots of searches have been unfruitful.  I am trying to port over a simple scripted field from scriptrunner for jira server to one for jira cloud.  Here is the old script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue


def parentLink = issue.getParentObject();


return parentLink


How would I rewrite this in Jira cloud scriptrunner as I can find the field in the rest API but can't actually show the value.  Thanks in advance!

3 answers

1 accepted

1 vote
Answer accepted

I was able to solve this problem in a slightly different manner with this script:

def issueKey = issue.key


def resp = get("/rest/api/2/issue/${issueKey}")
.header("Content-Type", "application/json")
.asObject(Map)
.body
resp["fields"]["parent"]["key"]

0 votes
Kai Sören Becker
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 20, 2023

Hi @James Mason 

welcome to the community. Scriptrunner Cloud is a little bit different than server.
You need to use the REST API to get the data you need.

Maybe this script will point you into the right direction: https://library.adaptavist.com/entity/sum-custom-field-related-epic-issues?tab=cloud

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 20, 2023

Welcome to the Atlassian Community!

Jira Cloud does not support scripted fields the way that server does.  You will need to use a standard custom field, and have your script populate it on change of data.

So i would need to take the built in field from advanced roadmaps that builds that parent link and dump it into another custom field to be able to retrieve it for viewing?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 20, 2023

Yes, exactly that.

On Server/DC, you can use a scripted field with "return <value from wherever>", but Cloud does not support the field type that SR injects on Server/DC, so we have to work with whatever field types that there is a REST API for.

It's not as good as the cleverness of proper scripted fields, because it has become a simple "copy field X to Y", but it works well enough for most (and we're working on proper scripted fields for Cloud with Atlassain)

So how would I read that field?  I can see the parent key when I run a get against the issue endpoint but I just can't return it

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 21, 2023

Same as you would read any other custom field.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events