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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

Jira Cloud Scriptrunner link issue on create

Im working on a Jira workflow post function that creates an issue. Im trying to add an update so that when it creates the new issue it also links it to the original issue.

When I run it this error keeps coming back

CorrelationId: 222dcd7a-b781-45f8-982d-da4dc4196fdd RUN Script identifier: a1fdfe6b-47f6-49c2-bb94-26a7a9014c0f ('Off-Board' transition made for issue HR-460) Took: 3500ms Logs: 2018-10-04 17:52:54.886 WARN - POST request to /rest/api/2/issue returned an error code: status: 400 - Bad Request body: {"errorMessages":["Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: com.atlassian.plugin.connect.plugin.auth.scope.InputConsumingHttpServletRequest$1@1e96084e; line: 1, column: 151] (through reference chain:[\"update\"])"]} 2018-10-04 17:52:54.928 INFO - POST /rest/api/2/issue asString Request Duration: 1902ms 2018-10-04 17:52:54.929 INFO - Run script completed


This is the code im running

def sourceSummary = issue.fields.summary
def exitDate = issue.fields.customfield_13200
def sourceKey = issue.key

.header("Content-Type", "application/json")
                    "summary"    : sourceSummary,
                    "customfield_13200" : exitDate,
                    "security" : [ "id" : "10101"],

                    "project"    : [
                            "id": "10001"
                    "issuetype"  : [
                            "id": "12550"
                            "inward":"relates to",
                            "outward":"relates to"

 Im pretty new to this and from other posts Ive seen this should work. Any pointers would be appreciated.

2 answers

1 accepted

0 votes
Answer accepted

Hi Alexander,

This error is a static type checking warning which indicates that the script does not understand the issue key and this may be due to the fact that you specified this before the post function which creates the issue meaning it may not be able to understand the issue key.

Could you please try using the example which I shared previosuly as this has been tested and contains no static type checking errors.

This example will create a new issue and link to it and is the recommend approach which we recomend using.

Could you please try the example we provided and if it solves your requirement accept this answer to mark it as correct for other users searching for a similar solution.



i see, the issue was that I didnt do .asObject(Map) for the create issue post.

The logs also threw an error about the outwardIssue not having a key so I changed id to key and it worked.


Thanks for the help!!!


where can I find more resources about what things like .asobject() or .asString() do? 

Hi Alexander,

Thankyou for confirming that your issue has been resolved .

I would suggest that you use the documentation site and the Jira cloud rest API site as help references to learn what APIs to use.

You may also find looking for an online groovy programming useful as this will teach you the groovy language which ScriptRunner uses.



Hi Alexandar,

Thank you for your question.

Can I please ask if you are trying to clone an issue and link the cloned issue to the   original issue during a workflow transition?

If this is the case then we provide a built in workflow postfunction inside of ScriptRunner for Jira Cloud called Clone Issue which is described inside of the documentation page located here.

We would recomend using this built in post function to achieve your requirement as you will be able to add it to the transition in the workflow where you need to clone the issue and will be able to conigure its form to specify the issue link type that should be used to link the issues.

Using the built in function will mean that it will be maintained as the Atlassian API changes meaning that it will continue to work when the API Changes and will not require yourself to make any manual script changes.

We also provide example scripts of how to update and how to link and issue inside the Run Script post function which are shown below the code box next to the examples link and you will be able to use the examples to see how to update and issue and to link an issue together using code in order to help you to write a custom script if you require one. 

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.



Hi Kristian,

I do not wish to clone the issue. I wish to create a new issue that only contains certain fields from the original issue. I am able to successfully create a new issue and copy the fields I want. The problem is that I cannot create the issue links.

Hi Alexander,

Can you please try looking at the example code which we have which shows how to create issue links and use this code inside of your script to create the issue links.

You can access this example code by adding in a Run Script post function and clicking the examples link below the code box and then the Link Issue link which populate the code box with example code on how to link two issues together.

You will then be able to take this code and add into your script and to modify it to link the issues together.



I see the example. Is it not possible to create the link under this post command?


 Im creating a new issue so I have the outward issue id but I dont have the id or key for the new issue I just created.

Hi Alexander,


Unfortunately you cannot create the link under the same command as you will need to get the issue key for the created issue after the post command has completed and you will need to call the rest API below in order to create an issue link. 


I have created a sample post function script which you can view here, which shows how to create an issue and then link the newly created issue to the issue which triggered the post function. 

You will be able to take this example post function and update this to achieve your requirement.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.



I see that makes sense.


For some reason when I try to do

def createdIssueKey = createIssue.body.key

I get the attached error.


Screen Shot 2018-10-10 at 10.02.06 AM.png

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events