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)
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})
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.