Link Component dropdwon value with Team Name
Asked by Deva:

Hi,

I am a novice with coding and I'm trying to create a confiforms, with these options.

I need help with two things

first one :

Component drodown contains Value1, Value2, Value3

I have 4 Teams in Jira, Team A, Team B, Team C \& Team D

if user selects Component Value1 then it should automatically map to Team A

similarly if user selects Value 2 then map to Team B

if user selects Value 3 then it should map to Team C \& Team D

OnCreated Jira ticket i should get a ticket with (1). Value1 - Team A (2). Value2 - Team B (3). Value B - Team C \& Team D

Second one:

2. on selecting anything from dropdown Value1/value2/value3 it should display another confiforms page


Answers:
author: Alex Medved _ConfiForms_
body: Hi

You can set up rules that set the values in a field based on the selection being made in another field <https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-Setvalue>

Or have a similar logic inside the IFTTT macro by using Velocity instructions #if()#end

<https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions+and+rules#ConfiguringConfiFormsIFTTTactionsandrules-CreateJiraIssue>

Alex

comments: author: Deva
body: Thanks Alex. can you please give some sample code/procedure to create Jira issue when one of the components selected from dropdown.

only one selected component should be linked to the created jira ticket

![Screen Shot 2022-10-31 at 4.12.40 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/223318i17FF2FE107006DF9/image-size/large?v=v2&px=999 "Screen Shot 2022-10-31 at 4.12.40 PM.png")


author: Alex Medved _ConfiForms_
body: Hi

Not sure how your field in ConfiForms is called but the structure in JSON mapping for components in JIRA REST APIs is

    "components": [{  "name": "someComponent"}],

Change someComponent to a reference of ConfiForms field \[entry.field_name.label\]

(where field_name) is the name of your components field in ConfiForms

Alex


author: Deva
body: Thanks Alex. it worked.


author: Alex Medved _ConfiForms_
body: Glad to hear

Accept the answer then;)


author: Deva
body: Alex, need one more support.

I want to assign Team when user selects component.

if user selects Microservices-Infra Component then "Team A" should be assigned

similarly if component is Security Testing then "Team B" should be assigned

could you plz share procedure to do this


author: Alex Medved _ConfiForms_
body: What do you mean by "assigning"

Assigned where? To some jira field?


author: Deva
body: yes, its jira field. with component i'm creating Jira ticket but need to assign relevant Team to the ticket. ![Screen Shot 2022-11-04 at 1.32.55 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/224090i018F8C466B2B45FA/image-size/large?v=v2&px=999 "Screen Shot 2022-11-04 at 1.32.55 AM.png")


author: Alex Medved _ConfiForms_
body: It is really in the [documentation](https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions+and+rules#ConfiguringConfiFormsIFTTTactionsandrules-CreateJiraIssue).. you can use Velocity templating

```
#set($comp = "[entry.Component]")
  #if($comp == 'A')  
   "customfield_XXX": "Team A",
  #end ?
  #if($comp == 'B')  
   "customfield_XXX": "Team B",
  #end ?
  #if($comp == 'C')  
   "customfield_XXX": "Team C",
  #end
```

Of course, I have no idea what field type is your Team field and what mapping it expects... Jira dropdowns expects something different <https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/>

But I truly believe you understand the concept

Alex


author: Deva
body: Hi Alex,

i tried but its not working. plz check this code and let me know what i'm missing here

set($comp = "\[entry.component\]")

if($comp == 'Microservices-Infra')

"customfield_14900": "2239",

end

if($comp == Microservices-RegUser)

"customfield_2239": "2239",

end

if($comp == Security Testing)

"customfield_14900": "3417",

end

if($comp == Regression),

"customfield_14900": "4482",

end } }


author: Deva
body: "customfield_14900": "2239", is the correct one. above one was typo error.

getting this error "Invalid format. Expected a ':' after a key at 619 \[character 12 line 13\]"


author: Alex Medved _ConfiForms_
body: Take a look at your IF conditions in the Velocity template... they are missing single quotes around the values to compare...

Also the mapping like

```
"customfield_14900": "2239"
```

is for text fields in Jira (see the documentation for Jira REST APIs)

if your "customfield_14900" field in Jira is a select field then the mapping is usually different

```
"customfield_14900": { "value": "2239" }
```

Alex


Tags: confiforms

confluence-server

server