Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Update a Two Part Custom Field in Jira with Python

Hello All,

 

   I am writing a python application to automatically create Jira issues, and am running into an issue with a required custom field that contains two parts.

 

   The custom field is called 'Program' and is identified as 'customfield_14700'.  When you choose the value / option for the Program field (ie. 'Pearl'), there is a second box next to it that is a sub-option (ie. G3 - SW).

 

   When you query the value of the custom field :

        > ticket_obj = jira.issue('MD-7347')
        > print ticket_obj.fields.customfield_14700

   Result :

        > Pearl - G3 - SW

   

   I am using a dictionary to build the create issue request, but am having a problem with the custom field.  So far I have :

 

        issue_dict = {
            'project':{'key':'MD'},
            'summary':'Automated Issue : This is a test',
            'description':'Sample description of the issue.',
            'issuetype':{'name':'Bug'},
            'customfield_14700':{'0':'Pearl', '1':'G3 - SW'}
        }

        new_issue = jira.create_issue(fields=issue_dict)

 

    I know the above customfield_14700 is wrong; it is the closest I can seem to find based on other similar questions.  

 

    I get the following when executing :

 

        response text - {"errorMessages":[],"errors":{"customfield_14700":"Could not find valid 'id' or 'value' in the Parent Option object."}}

 

   I am hoping I am missing something obvious; but am at a loss right now.

 

   Has anyone encountered this scenario / have any thoughts on how to populate values into a two part custom field?

 

   Appreciate any help / suggestions.

 

Thanks!

Dan.

 

 

1 answer

1 accepted

0 votes
Answer accepted
'customfield_14700':{'0':'Pearl', '1':'G3 - SW'}

Hope this helps: Cascading Selects return their contents in an array of null and 1, so try null instead of 0

Hello Kyle,

   Thank you for your suggestion!  We did notice the 'null' from one of our reports / exports to excel; unfortunately more or less the same response :

 

        issue_dict = {
            ...
            ...
            'customfield_14700':{'null':'Pearl', '1':'G3 - SW'}
        }

 

Response : 

        response text =  {"errorMessages":[],"errors":{"customfield_14700":"Could not find valid 'id' or 'value' in the Parent Option onject."}}

 

   Also tried various spellings (ie. Null, NULL); and tried a None: key as well; same result.  

 

Dan.

Try these two:

"customfield_12345" : [{"set" : {"value" : "parentVal", "child": {"value":"childVal"}}}]
"customfield_12345" : {"value" : "parentVal", "child": {"value":"childVal"} } 

This is creating issues via the REST api, correct? I assumed this

Technically yes, this is being done using the python-jira library for an application we are developing. 

The python-jira library allows us to work with Jira APIs from python.  

Okay, just wanted to make sure this wasn't python somehow interacting with the Java API through some sort of magic I haven't seen. Hopefully one of those two solutions above will help.

Tried the above suggestions :

For the first one :

        response text = {"errorMessages":[],"errors":{"customfield_14700":"Can not deserialize instance of com.atlassian.jira.issue.fields.rest.json.beans.CustomFieldOptionJsonBean out of START_ARRAY token\n at [Source: N/A; line: -1m column: -1]"}}

 

For the second one :

        We get an error that another custom field is required; however the error for customfield_14700 is no longer present.  I think this has solved the issue; I will resolve the other custom field and let you know shortly.

Thank you!

Kyle, thank you very much for your suggestions!  The second option resolved the issue and automation is working well now!

 

Solution is :

 

"customfield_12345" : {"value" : "parentVal", "child": {"value":"childVal"} } 

Thank you, it solved my problem as well; this has worked for me 

# https://jira.readthedocs.io/en/master/index.html
from jira import JIRA
import re

options = {
'server': 'https://jirahost.com/jira/',
'verify': False }
jira = JIRA(options, basic_auth=('userid', 'password'))

issue = jira.issue('PROJ-1')

issue.update(fields={'summary' : 'Re-assigned to John Doe' \
,'assignee': {'name':'johnd'} \
, "customfield_14510":{"value" : "Dec-18", "child": {"value":"25%"}} \
, "customfield_14511":{"value" : "Jan-19", "child": {"value":"75%"}} \
})

This helped me as well!

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you