Forums

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

How to get the issue key of the created issue on jira server using Atlassian python library

amaan khan August 2, 2022

I am using the below code to create a jira ticket and update a few custom fields at the time of creation. 

I want to update "customfield_13315" with the issue key of the ticket that I am creating example: TEST-123. Is there a way to do so? I have looked through the documentation but, where I am confused is that the issue key is created after the issue is created so would I need to update the field after the issue creation? 

How would I do this? Thanks.

from atlassian import Jira
import pandas as pd
from datetime import datetime

results = pd.read_csv('FILENAME')

jira = Jira(

url='https://jira.orgname.org/',

token='TOKEN'

)

fields = { "project": { "key": "PROJECT KEY" },
"summary": "this is the summary",
"description": "this is the description",
"issuetype": { "name": "type" },
"customfield_13308": { "value": "" }, 
"customfield_13309": { "value": "employee_id" }, 
"customfield_13310": { "value": "No" }, 
"customfield_13311": { "value": "No" },
"customfield_13312": { "value": "No" }, 
"customfield_15904": { "value": "No" }, 
"customfield_13307": results['amount'].sum(), #Amount
"customfield_13306": len(results), #Rows
"duedate": datetime.today().strftime('%Y-%m-%d'),
"customfield_13315"
}

jira.issue_create(fields)

 

 

1 answer

0 votes
Payne
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.
August 2, 2022

issue_create() returns an Issue object, so you can get the key from it and then update your issue.

Something like:

newIssue = jira.issue_create(fields)
newIssue.update(fields={"customfield_13315": { "value": newIssue.id})

Suggest an answer

Log in or Sign up to answer