Confiforms Create Jira Issue IFTTT and Control Flow with Velocity variables
Asked by Drew T:

I've been able to create jira issues using Confiforms IFTTT macros to date successfully, however, I want to include some velocity variables to dynamically control how the JSON is configured before it is sent to Jira. I want to use this to set a customfield id and its value. appName field is a dropdown containing options: Jira, Confluence.

e.g.

#if(${appName.label} == "Jira"})

#set ($customfield = "customfield_1234")

#set ($identifier = "\[entry.projectKey\]")

#end

#if(${appName.label} == "Confluence")

#set ($customfield = "customfield_4321")

#set ($identifier = "\[entry.spaceKey\]")

#end

{

"fields":

{

"project": { "key": "somekey" },

"issuetype": { "name": "Request" },

"description": "\[entry.reqInfo\]",

"$customfield": {"value": "$identifier"},

"issuetype": { "id": "7" }

}

}

I am getting either one of two errors depending on how I structure the macro body content, either using a no format macro or not.

1. With Velocity statements in macro body and json within No format Macro, I get the error

- Field '$customfield' cannot be set. It is not on the appropriate screen or unknown. However customfield_1234 is definitely on the correct screen.

2. All content in macro body with no No format macro OR All content in the No Format Macro within the IFTTT macro.

I've tried both options of velocity variables being declared at the start or embedding them within the JSON but get the following error

- Could not prepare JSON. Invalid format. A JSON Object must begin with '{'

@[Alex Medved _ConfiForms_](https://community.atlassian.com/t5/user/viewprofilepage/user-id/781630) Could you please help?!

I've followed the instructions at: <https://wiki.vertuna.com/display/CONFIFORMS/Creating+Jira+issue+from+Confluence+with+ConfiForms>

I've also tried the answer in:

<https://community.atlassian.com/t5/Confluence-questions/IFTTT-and-velocity/qaq-p/1499758>


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Drew T](/t5/user/viewprofilepage/user-id/4734306)

You have an extra } in the first line

This is how it should be

```
#if(${appName.label} == "Jira")
```

Alex

comments: author: Drew T
body: Hi Alex,

Sorry that extra bracket was a transcription error, only in my question.

Even with that fixed up, I still get the following error:

com.atlassian.sal.api.net.ResponseException: Error Communicating with Jira, {"errorMessages":\[\],"errors": {"$customfield":"Field '$customfield' cannot be set. It is not on the appropriate screen, or unknown,"}}

The customfields that I'm setting to the variable $customfield e.g. customfield_1234, are on the correct screen in jira.

The $customfield variable doesn't seem to be resolving to any value and it seems to be trying to pass in a customfield called '$customfield' which is causing the error.

What could be causing the variable to not be resolved??


author: Alex Medved _ConfiForms_
body: This only mens that the "customfield" variable gets unassigned

Which means neither it has Jira nor Confluence value in the appName field

Let me give you a complete example on how I test this

<http://recordit.co/4Mn051Rwy3>

Hope it helps

Alex


author: Drew T
body: That makes perfect sense, if a velocity variable evaluates to null it just returns the variable name.

I updated my work to just look at the field id values rather than the labels and it all works now.

The tip of using the PlainView macro for testing is really useful!

Thanks for your help and going to the effort of posting the recording.

Drew


Tags: confiforms

confluence-server

server