Using Confiforms Multi-select field need to POST values in jira Dashboard using Json

sunil kumar March 8, 2022

Using Confiforms fields Multi-select

impacted.jpg

  i have provided ID and Labels. When i am trying to pass values using JSon script as Custom field type: Impacted Service(s)

"customfield_26340": [[entry.impactedservice.asArrayMultiSelect]] 

 I am not getting any error message and it was not reflecting in jira ticket. using get method URL i got the below json response using this i am mapping in confiforms json values.

"customfield_26340": [
{
"self": "http://xxxxxxxxx:8081/rest/api/2/customFieldOption/100345",
"value": "NG - Trade",
"id": "100345"
},
{
"self": "http://xxxxxxxxxxxxxxxxxxxx:8081/rest/api/2/customFieldOption/100346",
"value": "API Banking",
"id": "100346"
}
], 

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 8, 2022

Hi

Are you sure you Jira field expects something like this as input?

"customfield_26340": ["100345", "100346"]

As this is what you are trying to pass from ConfiForms

I cannot tell what field type is your customfield_26340

But probably it accepts something like

"customfield_26340": [{"id":"100345"}, {"id":"100346"}]

In this case the mapping should be something like

"customfield_26340": [[entry.impactedservice.asArrayOfKVPairs(id)]]

Alex

sunil kumar March 9, 2022

Hi Alex,

I have used the above mapping case, It was not reflecting in jira dashboard.

"customfield_26340": [[entry.impactedservice.asArrayOfKVPairs(id)]] 

 in Jira Dashboard the field type looks like this

impacted.png

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 9, 2022

Does not look like a multi-select field to me. Does it allow a single value only to be selected?

Alex

sunil kumar March 9, 2022

Hi Alex,

customfield_26340 is Impacted service (s) 

sunil kumar March 9, 2022

No we can select Multiple values

sunil kumar March 9, 2022

Hi Alex,

I have selected multiple values and i get JSOn response.

"customfield_26340": [
{
"self": "http://xxxxxxxxxxxxx/rest/api/2/customFieldOption/100345",
"value": "NG - Trade",
"id": "100345"
},
{
"self": "http://xxxxxxxxxxxxxxxx:8081/rest/api/2/customFieldOption/100346",
"value": "API Banking",
"id": "100346"
}
],

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 9, 2022

So, when you create an issue in Jira via ConfiForms do you see the "customfield_26340" field has values?

sunil kumar March 9, 2022

No I am not able to see this customfield_26340 in jira Dashboard while updating or creating, but when i use get method URL to fetch the values , i am getting above json response and values are  assigned to that customfield_26340 field using that i have mapped in 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.
March 9, 2022

What do you mean by "Dashboard"? 

When browse to the created ticket, do you see the field filled? What JSON mapping do you use (full code)? 

sunil kumar March 9, 2022

I have created ticket in jira in that i have field type as Impacted Service(s):  so i have selected multiple values in that and i have updated that ticket. 

So i use get method url to fetch the information using postman i got the response like below.

"customfield_26340": [
{
"self": "http://xxxxxxxxxxxxx/rest/api/2/customFieldOption/100345",
"value": "NG - Trade",
"id": "100345"
},
{
"self": "http://xxxxxxxxxxxxxxxx:8081/rest/api/2/customFieldOption/100346",
"value": "API Banking",
"id": "100346"
}
],

 

Using this json response I am mapping in my confluence confiforms like in below

impactedservice.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 9, 2022

So, why do you put something like "ImpactedService" then you need to set a "customfield_26340" as Jira REST API expects and requires!?

And as I have mentioned and explained earlier...

sunil kumar March 9, 2022

Hi Alex,

When i used customfield_26340 it was not giving any error in confluence confiforms and changes are not reflecting in Jira.

But when i use impactedService in json it was not working and i am facing issue below.

"Impacted Service(s)":"Field 'Impacted Service(s)' cannot be set. It is not on the appropriate screen, or unknown."}}

So now i changed with customfield_26340 in my 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.
March 9, 2022

So, instead of understanding and fixing this error you decided to rename the field!?

OK, the error (and you really need to learn the Jira REST API and how it works) tells you that the field you are attempting to set is NOT on the Jira create issue screen and therefore cannot be set on create

You can verify it yourself - open the form in Jira for this project/issue type and try to find this "customfield_26340" field on that form

In order to set the field you need to have it on the (Jira) form... on the "Create Issue Screen"

Alex

sunil kumar March 10, 2022

Hi Alex,

Sorry for delay response

I am able to pass values using this mapping 

[[entry.Impactedservice.transform(label).asArrayOfKVPairs(value)]]

 

Thanks a lot for your prompt support

Like # people like this
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 10, 2022

Great, that is why it is important to understand what Jira expects from you - is it an array of IDs or labels.. and how the "key" part should be constructed. Sometimes it is an "id", sometimes it is a "value", sometimes it is a "name"

This page helps with that - https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/

Like sunil kumar likes this

Suggest an answer

Log in or Sign up to answer