How to use ConfiForms to create a JQL query & display the results?
Asked by 4armstar:

Hi,

I want to create a JQL query based on information entered by user via several ConfiForms Form Fields. The resulting JQL query will then be run to retrieve the JIRA fields that matches with the query.

I know how to create forms and display the result using ConfiForms but would like to learn how to do the above.

I am not able to find further examples on using ConfiForms field type 'JQL'. Appreciate any guidance from the gurus out there.

Thank you.


Answers:
author: Alex Medved _ConfiForms_
body: You can mix ConfiForms ListView with Jira issues macro (Confluence standard macro) to get something like this

![Screenshot 2020-10-23 at 20.03.27.png](https://community.atlassian.com/t5/image/serverpage/image-id/115492iCDDADF98B9061D1C/image-size/large?v=v2&px=999 "Screenshot 2020-10-23 at 20.03.27.png")

With storage format example

```
<ac:structured-macro ac:macro-id="d176be2f-a2a0-462b-a31e-fdf2cb28563d" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="4bbe175d-0201-4ca0-8b16-08b7b2970b19" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="e4d37510-f596-4ef1-a9b8-f549f4c01900" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">jql</ac:parameter>
<ac:parameter ac:name="fieldLabel">JQL</ac:parameter>
<ac:parameter ac:name="extras">Atlassian JIRA</ac:parameter>
<ac:parameter ac:name="type">jql</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="942cea8e-d7c9-457b-953f-0a352881c001" ac:name="confiform-list" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<p>JQL results count:?<ac:structured-macro ac:macro-id="8bb209ab-01e9-4c04-89b8-46453e6277fb" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">jql</ac:parameter>
</ac:structured-macro>
</p>
<h2>
<ac:structured-macro ac:macro-id="17ecc6b0-d762-4b88-8cee-4f8cfb44e79c" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">jql.jql</ac:parameter>
</ac:structured-macro>
</h2>
<p>
<ac:structured-macro ac:macro-id="dfd37966-7914-4cff-a36a-7856b833e1fb" ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">Atlassian JIRA</ac:parameter>
<ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name="jqlQuery">[entry.jql.jql]</ac:parameter>
<ac:parameter ac:name="serverId">144880e9-a353-312f-9412-ed028e8166fa</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
```

comments: author: tqtam
body: Hi Alex, it seems storage format is not enabled by my admin.

Is there a way to do this with the regular editor?

We want to be able to go through Confluence, allow the user to input a keyword and then search Jira issues summary field based on the keyword.


author: Alex Medved _ConfiForms_
body: You will need confluence editor to prepare the storage format as required.

Because you cannot give dynamic variables to "Jira" macro, as it tries to validate your input before "save" and it will fail for our "dynamic parameters"


author: tqtam
body: Is there a way to do this without using a Jira macro since we cannot send dynamic variable?


author: Erik Buchholz
body: I think this depends on your goal?

What do you (or your user) want to do with the found issues?

Your admins can send dynamic variable, if you give them the code.

Have you tried my approach with AppLinkService and Jira REST?

Regards,  
Erik


author: Erik Buchholz
body: Hi [@4armstar](/t5/user/viewprofilepage/user-id/3572429) ,

we also wanted to use the JQL field to find a issue and proceed with that issue.

We will use the [AppLink service](https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions#ConfiguringConfiFormsIFTTTactions-ApplinkService) with the [Jira REST search.](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-search-get)

To use the result you have to load the result into a ConfiForms field and use the [virtual function](https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions) asJSON.

Please find a minimal working example below.

Please note that the JQL may not contain any spaces. You can use other virtual functions to escape any invalid characters.

```
<ac:structured-macro ac:macro-id="5e3d56b1-d746-459b-8e10-bd1dbfa8e0bd" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">search</ac:parameter>
  <ac:rich-text-body>
    <p class="auto-cursor-target">
      <br/>
    </p>
    <ac:structured-macro ac:macro-id="a66a98af-909b-43c7-8293-fdfeede5d88e" ac:name="confiform-entry-register" ac:schema-version="1">
      <ac:parameter ac:name="embedded">true</ac:parameter>
      <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
      <ac:rich-text-body>
        <p>
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br/>
    </p>
    <p class="auto-cursor-target">
      <ac:structured-macro ac:macro-id="85d80c31-d5b0-4ac3-8a2a-fd9a7c6d0c6f" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">jql</ac:parameter>
        <ac:parameter ac:name="fieldLabel">JQL</ac:parameter>
        <ac:parameter ac:name="type">text</ac:parameter>
        <ac:parameter ac:name="required">true</ac:parameter>
      </ac:structured-macro>
    </p>
    <p class="auto-cursor-target">
      <ac:structured-macro ac:macro-id="e03d4422-d9e0-4248-88c2-321bac13a90f" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">result</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Ergebnis</ac:parameter>
        <ac:parameter ac:name="type">hidden</ac:parameter>
      </ac:structured-macro>
    </p>
    <p class="auto-cursor-target">
      <ac:structured-macro ac:macro-id="afd0945b-3596-46f4-8f64-620fd535bc39" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">total</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Anzahl der Ergebnisse</ac:parameter>
        <ac:parameter ac:name="type">number</ac:parameter>
      </ac:structured-macro>
    </p>
    <p class="auto-cursor-target">
      <ac:structured-macro ac:macro-id="9f1fa02a-b2b8-4239-b190-7e77f3abe970" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">issue</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Jira Vorgangsschl?ssel</ac:parameter>
        <ac:parameter ac:name="type">jira</ac:parameter>
      </ac:structured-macro>
    </p>
    <ac:structured-macro ac:macro-id="be383acb-80b4-44b0-b123-14d689828368" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="action">AppLink service</ac:parameter>
      <ac:parameter ac:name="event">onCreated</ac:parameter>
      <ac:parameter ac:name="extras2">/rest/api/latest/search?jql=[entry.jql]&amp;fields=key</ac:parameter>
      <ac:parameter ac:name="resultName">myjqlsearchresult</ac:parameter>
      <ac:parameter ac:name="who">GET</ac:parameter>
      <ac:rich-text-body>
        <p class="auto-cursor-target">
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p>
      <br/>
    </p>
    <ac:structured-macro ac:macro-id="8b73e91f-cc38-4b96-846a-f5b54dd53604" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
      <ac:parameter ac:name="event">onCreated</ac:parameter>
      <ac:parameter ac:name="title">entryId=[entry.id]&amp;result=${iftttResult_myjqlsearchresult}</ac:parameter>
      <ac:rich-text-body>
        <p>
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br/>
    </p>
    <ac:structured-macro ac:macro-id="9be13494-5fdc-4c7d-b05d-1f40ac6bee2a" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
      <ac:parameter ac:name="event">onCreated</ac:parameter>
      <ac:parameter ac:name="title">entryId=[entry.id]&amp;total=[entry.result.asJSON.total]</ac:parameter>
      <ac:rich-text-body>
        <p>
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br/>
    </p>
    <ac:structured-macro ac:macro-id="7ad13578-bbe9-41f5-9f1b-ca5fd1e07183" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
      <ac:parameter ac:name="event">onCreated</ac:parameter>
      <ac:parameter ac:name="title">entryId=[entry.id]&amp;issue=[entry.result.asJSON.issues[0].key]</ac:parameter>
      <ac:rich-text-body>
        <p>
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p class="auto-cursor-target">
      <br/>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
  <br/>
</p>
```

comments: author: Alex Medved _ConfiForms_
body: Wow! What a brilliant example!


author: sarvjeet kaur
body: Hi [@Erik Buchholz](/t5/user/viewprofilepage/user-id/3370115)

Can you please explain how to the [AppLink service](https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions#ConfiguringConfiFormsIFTTTactions-ApplinkService) with the [Jira REST search?](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-search-get)

Do you have any screen shots you can share?


author: Erik Buchholz
body: Hi [@sarvjeet kaur](/t5/user/viewprofilepage/user-id/4137242) ,

with the AppLink service you can use any configured AppLink. If the AppLink has an authentication included the IFTTT uses that. So you don't have to struggle with that.

Than you look for the right REST url at the documentation. Please note that cloud and server have slightly different versions and different documentation.

For a simple jql search we used

```
/rest/api/latest/search?jql=[entry.jql]&fields=key
```

\[entry.jql\] is the reference to the jql field of your form.

I added 'field=key' to reduce the data of the response.

![Screenshot-01_2020-10-26 MWE for Atlassian Community.png](https://community.atlassian.com/t5/image/serverpage/image-id/115636i216707B5D33AD8A9/image-size/large?v=v2&px=999 "Screenshot-01_2020-10-26 MWE for Atlassian Community.png")

![Screenshot-02_2020-10-26 MWE for Atlassian Community.png](https://community.atlassian.com/t5/image/serverpage/image-id/115637iBD0E875F752C718D/image-size/large?v=v2&px=999 "Screenshot-02_2020-10-26 MWE for Atlassian Community.png")

You can include the storage format of my MWE with the '\<\>' button in the upper right corner in edit mode. Please note that this button is not there if you create the page but only if you edit it.

![Screenshot-03_2020-10-26 Storage Format.png](https://community.atlassian.com/t5/image/serverpage/image-id/115638iCD71E3C881EA255D/image-size/large?v=v2&px=999 "Screenshot-03_2020-10-26 Storage Format.png")

Regard,  
Erik


author: Alex Medved _ConfiForms_
body: Hi

JQL field type in ConfiForms just returns the number of issues matching the JQL criteria given and that is the only purpose it has

As per documentation: <https://wiki.vertuna.com/display/CONFIFORMS/Accessing+field+values+and+properties> the field has only 2 properties

```
myfeld.jql
myfeld.count
```

(assuming your JQL field is named "myfield")

How do you plan to use it I am a little bit unsure... as it works with issues in Jira, executing given JQL, and not with fields (when you say: "retrieve the JIRA fields that matches with the query.")


Tags: confiforms

confluence-server

server