Concat fields from Confiforms over to Components in JIRA
Asked by Vivek Dokania:

Hi Atlassian Community,

I am a novice with coding and I have created my first ever form with Confiforms.

I need help with two things -

1. I want to map the multi-select field from confluence using confiforms (i.e. user inputs) over to Labels in JIRA.

For example: User selects ("Apple", "Grapes", "Oranges") in the multi-select field in the confiform and this should be created as Labels in JIRA as individual element. (Just to let you know the elements in the multi-select field doesnt have any spaces).

2. There are two fields in confiforms, Field1 (a single dropdown) and Field2(a single dropdown). I want to concat the user selection in the confiform as Field1 + Field2.

For example - Field1 has values (1. Anne, 2. Bob, 3. Charlie) and Field2 has values (1. X, 2. Y, 3. Z). If the user selects "Anne" in first field and "Z" in second field, then the output of "Anne_Z" should be going into the Components field in JIRA.

Any help with the JSON code would be really really helpful.

Thanks


Answers:
author: Alex Medved _ConfiForms_
body: To answer 1st part of your question:

For the components you will need to have a structure like this, in your JSON
>
> ```
> "components": [{"name":"XXXX"},{"name":"YYYY}]
> ```

From ConfiForms, when mapping your multi-value field in the JSON you will need to use the virtual function called "asArrayOfKVPairs(name)"

<https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions>

Basically to have something like

```
"components": [[entry.your_field_here.asArrayOfKVPairs(name)]]
```

where "**your_field_here**" is the name of the multi-value field you want to map as your components

comments: author: Vivek Dokania
body: Hi Alex,

Thanks a ton for sharing this.

The above notation helped me in resolving Issue 2.

But I am still having troubles with Issue 1.

Everytime, I try that I get the following error -

"errors":{"labels":"The label 'Apple Grapes' contains spaces which is invalid."}

Just that you know that if I go into JIRA and type Apple then ENTER then Grapes, it works for me and it creates two separate Labels in JIRA as Apple and Grapes (pic attached)![Labels in JIRA.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/52788i29A4E3326C75C1A9/image-size/large?v=v2&px=999 "Labels in JIRA.PNG")


author: Alex Medved _ConfiForms_
body: How do you map the labels field in Jira JSON and what type of the field is used in ConfiForms?


author: Vivek Dokania
body: Using the JSON code provided by you above.

```
"labels": [[entry.Platform.asArrayOfKVPairs(name)]]
```

the field in the confiform is a Multi-Select field.

Users can select more than one element in the box. The elements are shown up as TILE in the field.


author: Alex Medved _ConfiForms_
body: The example was for components field. Labels field in Jira is expected in a different format

```
 "labels": [
 "Apple",
 "GRAPES"
 ]
```

So, the mapping needs to be different

```
"labels" : [[entry.Platform.transform(label).asArray]]
```

if you want to send the label form your multi-select field, if you want to set IDs then

```
"labels" : [[entry.Platform.transform(id).asArray]]

or

"labels" : [[entry.Platform.asArray]]
```


author: Vivek Dokania
body: You are a genius...

All i used your code.. just a slight edit -

```
"labels" : [[entry.Platform.asArray(')]]
```

and it worked like a charm...

Thanks a lot ALEX... really appreciate your help.


author: Vivek Dokania
body: Hi Alex,

You have helped me previously and I need your help again now.

With your help I have successfully created my form.

Now, I am trying to have an IFTTT rule in the form, where the form would create a JIRA issue only when the form is APPROVED (i.e. Success)

For the Approval I have used the field type "Status - group your data".

So once the Approver, selects "APPROVED", I want to create an Issue in JIRA.

I have succeeded in creating JIRA issue without this condition. That being said, when the user submits the change, a JIRA issue is created.

But it fails, when I add the rule in the IFTTT as - entry.Status:success

Please help.

Thanks in advance.


author: Vivek Dokania
body: Hi Alex,

I got it working... All i need to do is to change the IFTTT to on Modified.

Thanks a lot


author: Alex Medved _ConfiForms_
body: You need to set the filter to **track the change**

Your condition for IFTTT shall be something like

```
hasChanged(Status):true AND Status:success
```

[See more about hasChanged function in our docs](https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions)


author: Vivek Dokania
body: Hi Alex,

I am trying to Clone JIRA tickets (based on the user input of the existing JIRA ticket).

Right now, I have already created the Confiform to create a New JIRA ticket, but now I want to use the Update JIRA ticket and want to link it to the existing JIRA ticket.

Is it something we can do using Confiforms?

Let's say Confiform created new JIRA # "AB-1540"

This Issue = duplicate

Issue = "AB-1112" (Existing JIRA ticket. It would be a field in Confirform to be filled by users)

Comment = "aaaaa"

![Clone.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/55862i03A68173017CD374/image-size/large?v=v2&px=999 "Clone.jpg")


author: Alex Medved _ConfiForms_
body: Yes, you can link issues with ConfiForms, basically with Jira REST API, for the documentation see <https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-edit-issues-6291632/>

ConfiForms only calls the create/update Jira REST API with what you tell it to use (JSON). and it is a matter of creating a proper JSON document for Jira API

Also, you can call ANY API with AppLink Service action in ConfiForms IFTTT - create/update Jira issue actions are just the "predefined" calls over the generic AppLink Service action


author: Vivek Dokania
body: Thanks a lot Alex... I would look into that.. really appreciate your inputs.


author: Tanmay Gadkari
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) [@Vivek Dokania](/t5/user/viewprofilepage/user-id/3064668)

I'm facing a similar issue that you guys resolved a couple of years ago. Hoping you can help.

I am trying to populate the Components field in my jira using a Confiforms that has a dropdown for my Infrastructure Component values... Here's one of the 100 different options i tried (final one based on comments above):

"components": \[\[entry.infracomponent.asArrayOfKVPairs(name)\]\],

I keep getting the *expected an object*error all the time.

Any help here would be appreciated.

comments: author: Alex Medved _ConfiForms_
body: If your field is a (single choice) dropdown then you can just have something like

```
"components":[{"name":"[entry.infracomponent.label]"}]
```


author: Tanmay Gadkari
body: I'm pathetic when it comes to responding here soon enough. This worked brilliantly. Thanks so much [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) ! Perfect solution as always.


Tags: confiforms

jira