Database Values custom field custom field accessible from xporter templates?

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

 

6 answers

1 accepted

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

 

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 

Hi Jeff Turner

 

Yes, in order to help you select the pretended data.


Kind Regards,
Fábio Antunes 

Hi Jeff Turner,

 

Great Solution, glad to know that everything is working as expected. 


Kind Regards,
Fábio Antunes 

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?

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?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

134 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you