Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Cloud Scriptrunner, on Create transition post function, how to link issue to query result issue

fhamel@addenergie.ca February 24, 2019

Hello Atlassian Community! This is a little challenge i have been tasked to resolve but have no experience what so ever in scripting .  I understand the principle and how to use Scriptrunner (so far)...but i am stuck at this step:

here is what we need:

When creating an issue, the user fills a custom fiel (CF [16900]) which represents the "serial number".  We have issue type "Serialnumber", where the serial number is in Summary field, and we would like the issue created to be linked to the matching "SerialNumber" type issue/Summary

Something like this in jql query language:

If

issuetype=serialnumber and Summary ~ "new issue's" CF[16900]

then

link issue to JQL query result issue

----------------

As a very "green" scripter, i have come up with this so far...but i'm pretty sure it's missing something or completely wrong...

Condition:

if issuetype=serialnumber and issue.field.summary = "new issue's" CF[16900]

 

If condition is met:

def cf='cf [11900]'
def query = '<SerialNumber>'
def issueId = issue.id

def link = post('/rest/api/2/issueLink')
  .header('Content-Type', 'application/json')
  .body([
  type: [ name: "Strong" ],
  outwardIssue: [ id: issueId ], // This is the issue that the link 'starts' at
  inwardIssue: [ key: 'EX-1' ] // this should be a variable representing the query result
])
.asString()
assert link.status == 201

Any help would be very much appreciated :)

1 answer

0 votes
fhamel@addenergie.ca February 24, 2019

.

Suggest an answer

Log in or Sign up to answer