Hello Atlassian Community! This is a little challenge i have been tasked to resolve but have no experience what so ever in scripting and 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 :)
Answer
Hi Frédérique,
Thank you for your question.
I can confirm that we have an example script located here which shows how you can create an issue and link back to it on the create transition in the workflow as well as an example of linking two issues together here
I can confirm that we also have an example of how to extract the values from custom fields on an issue in the documentation pages located here.
These examples should help to show the structure that you will require to create the script that you require.
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.
Regards,
Kristian
Hello Kristian,
Thank you for the script. The sript is almost what i need. The tricky part, where i am stuck is, i need a way to define the target as "the result of a JQLquery". This means it would be variable. Can you help?
Frederique
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Frédérique,
I can confirm thatto run a JQL query inside of your script you need to use the Search Rest API and I can confirm we have an example of how to do this inside the documentation in the page located here.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.