Set a value for a custom field when creating jira ticket

hoseinzarifi73 March 9, 2018

I have problem setting a value for a custom field when creating a change ticket using jira API vi Ruby.

custom filed name and id is:  customfield_14135:1

I am trying to set this custom filed like this: 

"customfield_14135:1"=> {"id": "21277", "value": "IPG Big Data"},

the id and value is correct but it gives me the following error:

400 Bad Request: {"errorMessages":[],"errors":{"customfield_14135:1":"Field 'customfield_14135:1' cannot be set. It is not on the appropriate screen, or unknown."}}

1 answer

1 accepted

3 votes
Answer accepted
Kyle Moseley
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.
March 9, 2018

Why do you have the :1 at the end of the custom field ID? You should try removing that. Custom field IDs never include things like that.

hoseinzarifi73 March 9, 2018

I did not configure that, the configuration of the ticket was done by Jira Admin which I am not. I just need to use that custom filed.

I was wondering if there is any way around it since i do not have the privilege to change the IDs?  

Kyle Moseley
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.
March 9, 2018

Let me back up for a second. JIRA custom fields always follow a format of "customfield_xxxxx". So the one you're referencing is very odd and I'm guessing wrong. I would attempt again after remove the trailing ":1". It does not appear to be a valid cf id because of that last part.

I think your JIRA admin gave you an incorrect cf id.

hoseinzarifi73 March 9, 2018

I check the custom field IDs using browser inspect tools (page Elements), i can fill up all the other custom fields except the mentioned one. I think I need to contact Jira admin and tell them to modify the ID

hoseinzarifi73 March 12, 2018

This is the reply that I got back from my Jira Admin

We cannot change the format for custom fields, it is an add-on by JIRA and we only have rights to add it to a screen.

Please let me know if there is any way for me to access this particular custom field with Ruby syntax?

Thank you

Kyle Moseley
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.
March 12, 2018

Your JIRA admin is correct. You need to reference the custom field ID "customfield_14135" and not what "customfield_14135:1".

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 12, 2018

The :1 is not part of a custom field ID, it's wrong.  Remove it and try again with a valid id.

hoseinzarifi73 March 12, 2018

The following are two of the custom fields residing in one page

<select class="select cascadingselect-child" id="customfield_14135:1" name="customfield_14135:1">


<select class="select cascadingselect-parent" id="customfield_14135" name="customfield_14135">

I need to access both if these custom fields.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 12, 2018

Those are html element ids, and useless to you in terms of remote API code.

You need to use the custom field id as Kyle says.

For cascading selects, you need to set the top level and then use child for the second half: 

{"value": "Top level value", child: {"value":"IPG Big Data"}}

Kyle Moseley
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.
March 12, 2018

It's a single custom field. Here's a groovy example of how it's done. In null, you will set parent. In 1, you will set child.

 

REST example

 "customfield_10001": {"value": "green", "child": {"value":"blue"} } 

 Java/Groovy example

{{null: parent} {1: child}}

I don't know what exactly this Ruby is expecting so use these above as examples.  Also, this sort of CF is known as a Cascading Select -- it is different than other selects in JIRA.

Kyle Moseley
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.
March 20, 2018

Hi. If this answer helped, please use the checkmark to accept the answer. Thanks!

hoseinzarifi73 March 20, 2018

Yes it worked, thank you

G V Shabareesh November 15, 2018

how can i get the custom fields_id and my code was to add custom field from jira api

and my doubts are in this value number how to set ??

and  i want to create cascading select while adding custom field

and in this value and child value how i want to set please any one help me.

"customfield_10001": {"value": "green", "child": {"value":"blue"} }

is this the way to do or i am going in wrong direction.

def create_custom_field(self):

    a = {
        "fieldName": "Story Points",
        "fieldType": "com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect",
        "value": "12"
       }
   b = self.jira.custom_field_option(fields = a)
   return b

Suggest an answer

Log in or Sign up to answer