Confiforms: Convert JQL Filter JSON Result to Table
Asked by JiraAdmin:

I have a form that executes a JQL search and stores the result in a field. I want to convert the JSON returned into a table containing the the JIRA Issues that were returned.  

Setup:

Form name: "search"

Field Definitions:

* result Field type: Text
* total Field type: Numeric, Render as number HTML field
* ![image.png](/t5/image/serverpage/image-id/348388iBFFDC4C019AB485D/image-size/large?v=v2&px=999 "image.png")

Using Confiforms IFTTT Integration Rules to execute the JQL Search:

* Event: onCreated
* Action: Applink Service
* Method: GET
* Service url: /rest/api/2/search/jql=\[entry.jql.urlencode\]\&fields=key,status,summary
* Result: myjqlsearchresult

*** ** * ** ***

Activity:

Confiforms IFTTT, Create/Update Field: entryId=\[entry.id\]\&result=${iftttResult_myjqlsearchresult}

Confiforms IFTTT, Create/Update Field:

Entry parameters: entryId=\[entry.id\]\&status=\[entry. result. asJSON. issues. fields.status.name\]\&total=\[entry.result. asJSON.t otal\]\&NewKeyList=\[entry.result. asJSON. issues. key\]\&Summaries=\[entry.result. asJSON.issues. fields. summary

Partial value of field "result"

result {"expand":"schema,names","startAt":0,"maxResults":1000,"total":309,"issues": \[{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"1911348","self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/issue/1911348","key":"CSSJMCAPS-16013","fields":{"summary":"CAP: 964252 - Decommission McAfee MNE v5.0 Agt. ISRP Due 2025-03-31","status":{"self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/status/10000","description":"To Do","iconUrl":"<https://cti-> jira.nam.nsroot.net/jira/images/icons/statuses/open.png","name":"To Do","id":"10000","statusCategory": {"self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/statuscategory/2","id":2,"key":"new","colorName":"default","name":"To Do"}l}), {"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"1911274","self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/issue/1911274","key":"CSSJMCAPS-16012","fields":{"summary":"CAP: 964228 - Perimeter Security Tooling Development Services is using end of v Due 2024-12-13","status":{"self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/status/10000","description":"To Do","iconUrl":"<https://cti-> jira.nam.nsroot.net/jira/images/icons/statuses/open.png","name":"To Do","id":"10000","statusCategory": {"self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/statuscategory/2","id":2,"key":"new","colorName":"default","name":"To Do"}lI), ("expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"1906362","self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/issue/1906362","key":"CSSJMCAPS-15992","fields":{"summary":"CAP: 964057 - Remediate one (1) Medium finding from Statement of Work (SOW) 313 Due 2025-09-05","status":{"self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/status/10000", "description":"To Do","iconUrl":"<https://cti-> jira.nam.nsroot.net/jira/images/icons/statuses/open.png","name":"To Do","id":"10000", "statusCategory": {"self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/statuscategory/2","id":2,"key":"new","colorName":"default","name":"To Do"}l}), {"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"1906527","self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/issue/1906527","key":"CSSJMCAPS-15991","fields":{"summary":"CAP: 964050 - Based on the planning outcome Citi Transfer Repository is not a Due 2025-07-11","status":{"self":"<https://cti-> jira.nam.nsroot.net/jira/rest/api/2/status/10000", "description":"To Do","iconUrl":"<https://cti-> jira.nam.nsroot.net/jira/images/icons/statuses/open.png","name":"To Do","id":"10000","statusCategory": {"self":"<https://cti->

*** ** * ** ***

What is happening:

I have unsuccessfully tried several methods and settle on using Confiforms PlainView.   
I started with hardcoded values for the fields:  

ConfiForms PlainView \| formName = search \| renderAs = Table

\<tr\>  
\<td\>\[entry.result.asJSON. issues \[0\].key\]\</td\>  
\<td\>\[entry.result.asJSON. issues \[0\].fields.status.name\]\</td\>  
\<td\>\[entry.result. as JSON. issues \[0\]. fields.summary\]\</td\>

\</tr\>  
\<tr\>

\<td\>\[entry.result.asJSON. issues \[1\].key\]\</td\>  
\<td\>\[entry.result.asJSON. issues \[1\].fields.status.name\]\</td\>  
\<td\>\[entry.result. as JSON. issues \[1\]. fields.summary\]\</td\>  
\</tr\>

Which results in the following:

![image.png](/t5/image/serverpage/image-id/348389i5B99D7CDCE75D2AB/image-size/large?v=v2&px=999 "image.png")

I then changed the PlainView to:

ConfiForms PlainView \| formName = search \| evaluate = true \| renderAs = Table  

#set( $count = "\[entry.total\]" )  
#foreach( $ctr in \[1 .. $count\] )

\<tr\>  
\<td\>\[entry.result.asJSON. issues \[$ctr\].key\]\</td\>  
\<td\>\[entry.result.asJSON. issues \[$ctr\].fields.status.name\]\</td\>  
\<td\>\[entry.result. as JSON. issues \[$ctr\]. fields.summary\]\</td\>

\</tr\>

#end  

Which produces no output. From what I can find, it appears that the variable $count is a string so the #foreach loop does not recognize the a sting so falls thru.  

I tried removing the quotes from \[entry.total\] and get the following error:  
Could not process this PlainView as a Velocity template: Error occurred rendering template content Encountered "entry" at getRenderedContent\[line 1, column 17\] Was expecting one of: "\[" ... "\]" ... "{" ... ... ... "true" ... "false" ... ... ... ... "(" ...  

Any suggestions? Thank you


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@JiraAdmin](/t5/user/viewprofilepage/user-id/5448699)

This thing is a text, not numeric

```
#set( $count = "[entry.total]" )
```

And therefore cannot be used in the Velocity as a numeric variable

See this discussion for the reference

<https://community.atlassian.com/t5/App-Central-questions/Confiforms-how-to-add-a-month-to-a-date/qaq-p/2809757>

So, the "loop" needs to be something as below

```
#foreach ($ctr in [1..$Integer.parseInt($count)])
```

Alex


Tags: confiforms

addon-com.vertuna.confluence.plugins.confiforms

confluence-data-center

data-center