Greetings,
I am using the Database Values plugin to import tabular data into JIRA issues. For instance, data about a 'Client' associated with an issue:
Screenshot.png
I'd now like to use Xporter to generate PDFs incorporating this client info.
The getCustomFieldValue()
output of this custom field is actually an java.util.ArrayList
, where each value is an ArrayList
containing two Strings, a key and a value. In pseudocode:
Client Info = [ ["Client name (legal)", "Sample Client Inc."], ["Client name (short)", "sampleclient"], ["Technical Contact First Name", "Joe"], ["Technical Contact Last Name", "Bloggs"], ..... ]
Is it possible to access the values of such a custom field structure in Xporter templates? I've tried ${Client Info.Client name (legal)}
but that doesn't work.
Thanks,
Jeff
Hi @Fábio Antunes,
Thanks for the pointer, I figured out a solution. I wrote a Groovy scripted field that exposes the table's data as a Javascript. The Groovy script is:
// Groovy scripted field to expose a Database Value custom field (tabular data) // as a Javascript hash. // https://answers.atlassian.com/questions/23758594/answers/23759060 import com.atlassian.jira.component.ComponentAccessor import groovy.json.JsonOutput cf = ComponentAccessor.customFieldManager.getCustomFieldObject(10502) // Client Info cfVal = issue.getCustomFieldValue(cf) valMap = cfVal.inject([:]) { result, item -> result[item[0]] = item[1]; result; } return JsonOutput.toJson(valMap)
This returns text of the form:
{"TITLE":"VAL", "Client name (legal)":Sample Client Inc.", ....}
Since my Database Values field is called Client Info
, I named this scripted field Client Info JSON
. Then in my xporter template, I use it with:
Hello %{ var info = ${Client Info JSON}; info[“Billing Contact First Name”]},
Regards,
Jeff
Hi Jeff Turner,
Great Solution, glad to know that everything is working as expected.
Kind Regards,
Fábio Antunes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jeff Turner
Currently Xporter for JIRA does not support Database Values plugin and for that reason it is not possible to access the values that way. The workaround is use javascript to get the data from the value returned by the custom field.
Could you perform an export of that custom field and paste here the generated value to the exported file ?
Kind Regards,
Fábio Antunes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I use also xporter and crm for JIRA. When i export the custom dictionary - custom field it gives me the dictionary field id number (not the value, fo example not the user name just that id number).
Does anyone have idea?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fábio,
Thanks for the help. When you say generate an "export", do you mean the text that ${Client Info} expands to? With the idea being that the text can be parsed with Javascript?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.