Confiforms sending Labels to JIRA
Asked by Rayman Bacchus:

For the life of me I cannot figure out why this is not working: When posting to JIRA I have this:  
"labels": \["WOF-Intake"\], and it works as expected.  

THe issue I have is that I have several choices (6) and I want a different label depending on choice:

#if(${ProductFamily.id} =='01')   
"labels": \["FC-Prevent","WOF-Intake"\],  
#end  

#if(${ProductFamily.id} =='02')   
"labels": \["FC-Detect","WOF-Intake"\],   
#end

#if(${ProductFamily.id} =='03')   
"labels": \["FC-Response","WOF-Intake"\],   
#end

#if(${ProductFamily.id} =='04')  
"labels": \["FC-Performance","WOF-Intake"\],   
#end

#if(${ProductFamily.id} =='05')  
"labels": \["FC-Prevent-CIAM","WOF-Intake"\],  
#end

#if(${ProductFamily.id} =='06')  
"labels": \["FC-Integration","WOF-Intake"\],   
#end

I have a Multiselect field called **ProductFamily** with the following options:

|--------|---------------------------|
| **Id** | **label**                 |
| 01     | Fin Crimes Prevent        |
| 02     | Fin Crimes Detect         |
| 03     | Fin Crimes Response       |
| 04     | Fin Crimes Performance    |
| 05     | Fin Crimes Prevent - CIAM |
| 06     | Fin Crimes Integration    |


Answers:
author: Alex Medved _ConfiForms_
body: Hi

see how values in multi-value fields could be checked in velocity <https://wiki.vertuna.com/display/CONFIFORMS/IFTTT+macro+body+evaluates+as+Velocity+template>

Alex

comments: author: Rayman Bacchus
body: THanks Alex!   
THis "almost" worked. I now have this:

#if(${ProductFamily.hasId("01")})  
"labels": \["FC-Prevent","WOF-Intake"\]  
#end  

#if(${ProductFamily.hasId("02")})   
"labels": \["FC-Detect","WOF-Intake"\],  
#end  

#if(${ProductFamily.hasId("03")})  
"labels": \["FC-Response","WOF-Intake"\],   
#end

#if(${ProductFamily.hasId("04")})   
"labels": \["FC-Performance","WOF-Intake"\],   
#end

#if(${ProductFamily.hasId("05")})  
"labels": \["FC-Prevent-CIAM","WOF-Intake"\],   
#end

#if(${ProductFamily.hasId("06")})   
"labels": \["FC-Integration","WOF-Intake"\],   
#end   

The issue being that if multiple ProductFamily's are selected in the multi-select I run into a duplicate field "labels" issue  


author: Rayman Bacchus
body: I should be able to do this with multiple IFTTT's saying to update jira but wondering if there is a simpler solution


author: Alex Medved _ConfiForms_
body: It is a [Velocity](https://velocity.apache.org/engine/1.7/user-guide.html) templating - you definitely can do more in a template :-)

For example

```
#set($labels = [])#set($added = $labels.add("WOF-Intake"))#if(${ProductFamily.hasId("01")}) ?#set($added = ${labels.add("FC-Prevent")})#end#if(${ProductFamily.hasId("02")})? #set($added = ${labels.add("FC-Detect")})#end#if(${ProductFamily.hasId("03")})? #set($added = ${labels.add("FC-Response")})#end#if(${ProductFamily.hasId("04")}) #set($added = ${labels.add("FC-Performance")})#end#if(${ProductFamily.hasId("05")}) #set($added = ${labels.add("FC-Prevent-CIAM")})#end#if(${ProductFamily.hasId("06")}) #set($added = ${labels.add("FC-Integration")})#end   "labels": ?[#foreach( $lab in $labels ) #if($velocityCount > 1),#end "${lab}" #end],
```

Alex


author: Rayman Bacchus
body: Thanks as always Alex. THis solution worked. I guess I need to learn Velocity to continue with my Confiforms skill, but as always i thank you for your solution.


author: Alex Medved _ConfiForms_
body: Not for ConfiForms... mainly for ConfiForms to Jira integration and the effective usage of offered tools :)


Tags: confiforms

confluence-data-center

data-center

jira