Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confiforms Create Jira Issue IFTTT and Control Flow with Velocity variables

Drew T
Contributor
September 7, 2023

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_ 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

 

 

 

1 answer

1 accepted

0 votes
Answer accepted
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 8, 2023

Hi @Drew T 

You have an extra } in the first line

This is how it should be

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

Alex 

Drew T
Contributor
September 11, 2023

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??

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 11, 2023

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

Like Drew T likes this
Drew T
Contributor
September 12, 2023

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events