Using confiforms field type dropdown and checkbox i need to pass value to update jira ticket

sunil kumar March 3, 2022

Using confiforms field type dropdown for Impacted Service(s),Country,PSS Priority,Target Version(s and checkbox Applications Impacted, i need to pass value using json to update jira ticket but when i am trying to update it i was facing the below issue.

  • com.atlassian.sal.api.net.ResponseException: Error communicating with Jira, {"errorMessages":[],"errors":{"priority":"Could not find valid 'id' or 'name' in priority object.","Applications Impacted":"data was not an array"}}

 

Cash' passed for customfield 'Applications Impacted'."

Please do me a needful

Waiting for your positive response

Thanks,

Sunil G

1 answer

0 votes
Alex Medved _ConfiForms_
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 3, 2022

Hi

How do you map a "priority" field in ConfiForms JSON mapping?

It should be something like

"priority": {
   "name": "Critical"
}

Or 

"priority": {
   "id": "priority id"
}

What do you have?

Alex

sunil kumar March 4, 2022
"key": "[entry.keyCF]",
            "fields": {
                        "project": {
                                    "key": "DCDAPROD"
                        },
                        "summary": "[entry.summaryCF]",
                        "description": "Testing Successful",
      "customfield_18945": "[entry.serviceName]",
                        "customfield_12265": "[entry.Acceptancecriteria]",
                        "priority": "[entry.priority.id]",
                        "customfield_14004": "[entry.ApplicationsImpacted.id]"
sunil kumar March 4, 2022

I am using like this in my json script

Alex Medved _ConfiForms_
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 4, 2022

You can probably see it yourself and fix, but... see how you have the priority field mapped and how I was suggesting it should be mapped...

Alex

sunil kumar March 7, 2022

Using this field type I have maped in my confiformsissue.jpg

After using get method url I am able to fetch the id information using that I have mapped in inside the field as options.

 

issue2.jpg

Using Json Script I have modified for posting in jira

jsonerror.jpg

Alex Medved _ConfiForms_
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 7, 2022

Looks like a misunderstanding here

OK... here is the steps you need to do

Change the 

"priority": "[entry.priority.id]",

to

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

In your mapping

Alex 

sunil kumar March 7, 2022

HI Alex,

Thanks for your prompt response.

I am able to access now.

And i have done same for another field  using checkbox for Impacted Services Using Api i am able to fetch id and value for impacted services using below json i am typing to update in jira.

applicaiton.jpg 

And using Json:

"customfield_14004": { "value": "[entry.customfield_14004.label]" }

Error :

  •  com.atlassian.sal.api.net.ResponseException: Error communicating with Jira, {"errorMessages":[],"errors":{"Applications Impacted":"data was not an array"}}

And for Impacted services i have used the same field has a dropdown i am facing same issue while updating ticket.

 

Used Json value inside:

"customfield_14004": { "value": "[entry.customfield_14004.label]" }

Is i am using correct field for  Impacted Service in confiforms?

Alex Medved _ConfiForms_
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 7, 2022

I cannot tell that, as I have no idea what your "customfield_14004" in Jira is - what type is it..

But it's clearly something else than what you put - seems to expect an array

See what different Jira field types expect https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/

Alex

sunil kumar March 7, 2022

Hi Alex,

Sorry that was an Applications Impacted field i am using for customerfield_14004

 

"customfield_14004": [
{
"self": "http://xxxxxxxxxxxx/rest/api/2/customFieldOption/xxxx",
"value": "CADM",
"id": "xxxx"

It showing like this in my API

Kurt Willrich January 20, 2023

@Alex Medved _ConfiForms_ is this the same for when creating an Jira Issue at the same time?  I tried and can't seem to get it to work with that syntax (everything except the priority field works).  I get the error that 'priority cannot be set, it wasn't found on the screen'.  I'm guessing I'm trying to access it incorrectly.  I tried using both the field id and label:  

{

"fields": {
    "project":
    {
        "key": "XXXXX",     //not my actual project key, just removed for this post
        "id": "XXXXX"        //not my actual project ID, just removed for this post
    },
#set($maint = "[entry.maintenance]")
#if($maint == "Maintenance Required")
    "customfield_13212": [ {"value": "[entry.maintenance]"} ],
#end
    "customfield_10507": "[entry.fiscalYear]",
    "customfield_13224": "[entry.fundingDocument]",
    "customfield_12733": [entry.estimatedCost],  
    "customfield_20109": ["[entry.customerActivity]"],  
    "customfield_13117": ["[entry.productType]", "[entry.maintenanceType]"],
    "customfield_12744": "[entry.requiredDate]",
    "assignee": {"name": "adubois"},
    "customfield_13227": {"name":"[entry.customerName]"},
    "customfield_11309": "[entry.startDate]",

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

    "customfield_11308": "[entry.endDate]",
    "customfield_14614": "[entry.itprNumber]",
    "customfield_14905": "[entry.localTrackingNumber]",
    "summary": "[entry.summary]",
    "issuetype": { "name": "Contract Package"},
    "description": "[entry.comments.escapeJSON]"

    }
}

Alex Medved _ConfiForms_
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.
January 20, 2023

This error just tells you that priority field cannot be set as it does not exist or is not present in jira create/edit issue screen

This is not about what you set, but if it’s possible to set

Alex

Kurt Willrich January 20, 2023

@Alex Medved _ConfiForms_ success! Thanks for the easy solution! (and for being very responsive in general on this forum, it is very much appreciated!)

SKAdmin July 5, 2023

@Alex Medved _ConfiForms_ - Curious about Jira checkbox fields as well.

When I use a single choice for the checkbox it works, but when I try to add a second condition it stops working. 

#if(${1needed.label} == 'Yes') "customfield_18700": [{"value": "Option1"}], #end 

#if(${2needed.label} == 'Yes') "customfield_18700": [{"value": "Option2"}], #end 

 

Tried to use set, but that isn't working either.

#set ($customfield_18700 = ' ' )

#if(${1needed.label} == 'Yes') #set ($customfield_18700 = '{"value": "Option1"}') #end #if(${2needed.label} == 'Yes') #if($customfield_18700 != ' ' ) #set ($customfield_18700 = $customfield_18700 + ',') #end #set ($customfield_18700" =$!{customfield_18700} + {"value":"Option2"}') #end #if($customfield_18700 != ' ' ) "customfield_18700" : [${customfield_18700}], #end

Error -  Could not prepare JSON

Alex Medved _ConfiForms_
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.
July 6, 2023

The error tells you that the logic you have put in a your template generates an invalid JSON

Hard to tell what is wrong by looking at the snipped, but the error should also show the resulting document that it could not accept

That should give you a hint what is missing

Alex

Suggest an answer

Log in or Sign up to answer