[Confiforms] Webservice rest api with multiselect field

Xavier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2018

Dear all,

In a Confluence page, using Confiforms, I try to use "consume" a DB dropdown multiselect values field (cst16000) to a WebService using Rest API Jira (to create a Jira ticket with provide data from my page).

The need is to push all values from this dropdown to the Insight Object Custom Field (customfield_16000) of Jira ticket I want to create.

It works well, except when I select multiple values on my dropdown.

 

On my IFTTT integration rules, I add a 'No format' block, with this kind of data (below code runs when select only one value)

 

{
    "fields": {
       "project": {
          "key": "XXX"
       },
	   "reporter" : {
			"name":"[user.name]"
		},
	   "summary":             "[entry.summary.escapeJSON]",
           "description":         "[entry.desc1.escapeJSON]",
	   "customfield_16000" :  [{"key": "[entry.cst16000.id]"}],
	   "issuetype": {
          "name": "YYYY"
       }
   }
}

 

Manually, I can populate multiple values like this:

"customfield_16000" : [{"key": "KEY1"}, {"key": "KEY2"}],

 

How I can have all my values under an array ?

 

In other way, I try to use a Insight Object field type (runs as I can select only one value). But when trying to use an "Insight object (multiselect)", I have no the option to select the Object Type (as proposed with "Insight Object dropdown." So what is the difference between those two kind of fields ?

How I can use Insight Object (multiselect) with the rest api to have the same result ?

 

thanks in advance.

Regards

1 answer

1 accepted

2 votes
Answer accepted
Xavier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2018

I finally found using virtual function:

 

[[entry.cst16000.transform(id).asArrayOfKVPairs(key)]]

 

reagrds

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.
December 11, 2018

ConfiForms has a bunch on "virtual functions" you can apply on the data to transform it the way you need, the full list could be found here - ConfiForms virtual functions

Sana Safai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 19, 2022

Just wanted to add that I changed id to objectKey to make it work. In your example it would be:

[[entry.cst16000.transform(objectKey).asArrayOfKVPairs(key)]]
SPadalkar October 2, 2024

Hi @Alex Medved _ConfiForms_ ,

 

You have helped me with this before where

"customfield_30984": [[entry.FArea.asArrayOfKVPairs(value)]],

worked in the past. This was paired with the dropdown (FArea) that was using Webservice Dynamic Multi label and the dropdown list was populated via an excel attachment. The connection to the attachment breaks and dropdowns appear empty every so often. 

So I am trying to switch to a Jira API to get the list of options.  From the same Jira project where I am ultimately creating tickets. I switched the dropdown to Webservice Multi Select and loading the options using the following Jira rest API. The dropdown is showing the list of options successfully. 

/rest/api/2/issue/createmeta/<project>/issuetypes/9?expand=projects.issuetypes.fields

 

But while building the Jira payload, the following combos are failing.

[[entry.FArea.asArrayOfKVPairs(value)]],

[[entry.FArea.transform(id).asArrayOfKVPairs(value)]]

[[entry.FArea.transform(objectKey).asArrayOfKVPairs(value)]]

[entry.FArea.transform(id).asArrayMultiSelect()]


I am looking to convert the selection to this format

[{"value": "value1"}, {"value": "value2"}]

 

Appreciate your help.

SPadalkar October 2, 2024

This worked. :) 

[[entry.FArea.transform(value).asArrayOfKVPairs(value)]]

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.
October 2, 2024

There is really not much to guess... How the field is configured (all details)? 

Also, have not you tried to figure out why the reading from excel does not work for you? Could it be a permissions issue or it does not work at random? 

Like SPadalkar likes this
SPadalkar October 14, 2024

Hi Alex, @Alex Medved _ConfiForms_ ,


Sorry, missed your message. 

Our guess is the excel link was broken during the AMI rotation due to missing indexes. After reindexing the project it started working. Our Jira admins had to do it for us. 

<p>
<ac:structured-macro ac:macro-id="1b6fa537-0202-405a-8220-a84c13af7059" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="mapping">values.(fieldId=customfield_30984).allowedValues|value|value</ac:parameter>
<ac:parameter ac:name="fieldName">FArea</ac:parameter>
<ac:parameter ac:name="fieldLabel">Functional Area Select</ac:parameter>
<ac:parameter ac:name="values">/rest/api/2/issue/createmeta/<project>/issuetypes/9?expand=projects.issuetypes.fields</ac:parameter>
<ac:parameter ac:name="extras">89f846f264788bfaf58c4efbf05de4eb</ac:parameter>
<ac:parameter ac:name="type">wsmultiselect</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>

Do you have a concern with using the webservice to pull the list from Jira? I am seeing a couple of issues. 

  • After the change to pull dropdown options from Jira, the form started showing error when login expires. This makes me think I should come up with a way to cache the list locally and come up with a way to show an appropriate error message.
  • I am pulling options for three different dropdowns from the same Jira project. But since the URL is configured in each field, it's making the same call to Jira three times and using only the data it needs.

What would be the best way to make one call, cache it and populate select options for all three dropdowns? I am now also wondering at what point using a confiforms form becomes an unnecessary step, I should try to build the form in Jira somehow. I would have done that if I did not need admin privileges to make changes to fields and screens. :(


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.
October 15, 2024

Hi

1. You can switch to some service accounts to do that. (workaround the possibility of expired logins for your users)

2. Yes, it does each request for each field. This should not be a big issue, as the data amounts are small. And when the call is absolutely the same (same URL) - ConfiForms caches it within the same request (user http request)

Alex

Like SPadalkar likes this
SPadalkar October 15, 2024

1 - The user login actually works well, as the automation uses logged in users identity to create Jira tickets. For now, I will just add a note at the top of the form asking users to re-login if they see the error. 
2- Great, I was thinking that too. Yes, it is the exact same request. (/rest/api/2/issue/createmeta/<project>/issuetypes/9?expand=projects.issuetypes.fields) that gets all the metadata for the issuetype. Each webservice dropdown field picks a different root to pull the select options to the matching Jira field. 

Thanks for your help. 

SPadalkar October 24, 2024

@Alex Medved _ConfiForms_ ,

Another related question. Let me know if I should create a separate thread/post. 

The list appears empty to users if they are logged into wiki but not in Jira. What's the best way to force the login while loading the screen. Is there an example where this is done?

Thanks

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.
October 24, 2024

I suggest to use the service account to load these options and not rely on the application links and if the user is logged in into Jira or not

Like SPadalkar likes this
SPadalkar October 24, 2024

But then tickets created would use the service account as a reporter? I guess in my payload I can set the reporter.

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.
October 24, 2024

Not directly related and not necessarily (different modules - field definition and the IFTTT with a possibility use different connection types)

You can have a reporter field to be set explicitly to "current user" ([entry._user]), assuming you have the same user names in Confluence and Jira

SPadalkar October 24, 2024

yes, we do. And it has worked beautifully so far. :) 

I will test different connection type. 

Thank you as always for your quick response. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events