Forums

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

Jira query to create an issue with relate to

Markisio
Contributor
September 28, 2023

HI there

 

I am trying to create a jira issue using IFTTT Integration Rules within confiform, what I need help is how to set issuelinktype relate to with list of epics that entered by the user in confifrom

 

in Confiform I have the following fields 

summary, priority, relateTo <-- this is list of jira issues/epics

 

This is what I have 

 

{

"fields":

{

"project": { "key": "XYZ" },

"priority": { "name": "[entry.priority.label]" },

"summary": "[entry.summary]",      

"issuetype": { "name": "Task" }

}

}

 

wondering how I can add Relate To within Issue Link Type

 

thanks 

1 answer

1 accepted

0 votes
Answer accepted
Alex Medved _ConfiForms_
Community Champion
September 28, 2023

Hi @Markisio 

Do you know how the "relateTo" is set in Jira REST API? What is this? is this an issue links or a special custom field?

Alex

Markisio
Contributor
September 28, 2023

hi @Alex Medved _ConfiForms_ 

sorry relateTo is a confiform field in confluence, I am using data from confiform to create jira ticket, what I want to add the value from confiform field (relateTo) to Jira issue/ticket under Issue Links --> relates to. screen shot below from jira

I think that's the field in jira  issueLinkType = "relates to" , don't think its custom field 

Screen Shot 2023-09-28 at 12.15.15 PM.png

Alex Medved _ConfiForms_
Community Champion
September 28, 2023

I think this answers your question https://confluence.atlassian.com/jirakb/how-to-use-rest-api-to-add-issue-links-in-jira-issues-939932271.html or at least gives an idea on how to set it up

Markisio
Contributor
October 3, 2023

thanks @Alex Medved _ConfiForms_ haven't implemented yet, but it helps. However how would that work for list of relateTo, can I do for loop in query?

Alex Medved _ConfiForms_
Community Champion
October 3, 2023

Could use Velocity foreach

#foreach(${ticket} in ${jiraTickets.getIds()})
"add":{
"type":{
"name":"Blocks",
"inward":"is blocked by",
"outward":"blocks"
},
"outwardIssue":{
"key":"${ticket}"
}
}

#end

Assuming the field to hold multiple JIra issues is called jiraTickets

Alex 

Markisio
Contributor
October 6, 2023

thanks @Alex Medved _ConfiForms_ 

 

I did the following 

 

#if(${relateTo}) "update":{ "issuelinks":[{ #foreach(${ticket} in ${relateTo.getIds()}) "add":{ "type":{ "name":"Relates", "inward":"relates to", "outward":"relates to" }, "outwardIssue":{ "key":"${ticket}" } }, #end }] }, #end

 

result

 

"update": {
"issuelinks": [{
"add": {
"type": {
"name": "Relates",
"inward": "relates to",
"outward": "relates to"
},
"outwardIssue": {
"key": "X1"
}
},
"add": {
"type": {
"name": "Relates",
"inward": "relates to",
"outward": "relates to"
},
"outwardIssue": {
"key": "X2"
}
}
}]
},

however I am getting Invalid format. Duplicate key "add" :( 

Alex Medved _ConfiForms_
Community Champion
October 6, 2023

Well, regarding the JSON format what Jira expects please see the documentation on Jira REST APis... there is not much I can help you with

But the same keys in JSON objects are not possible as per JSON format

Markisio
Contributor
October 10, 2023

hi @Alex Medved _ConfiForms_ 

 

I got it working, however it only works with single ticket, it seems there is an existing issue: https://jira.atlassian.com/browse/JRACLOUD-81845 do you know when that fix so I can use the for loop?

 

{ "fields": { //FIELDS elements } #if(${relateTo}) , "update":{ "issuelinks":[ { "add":{ "type":{ "name":"Relates", "inward":"relates to", "outward":"relates to" }, "outwardIssue":{ "key":"[entry.relateTo.get(0).id]" } } } ] } #end }

Alex Medved _ConfiForms_
Community Champion
October 10, 2023

Unfortunately I cannot force Atlassian to fix the bug... Please ask them about it

Alex

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events