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

This widget could not be displayed.

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

This widget could not be displayed.

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 

This widget could not be displayed.

Hi Jeff Turner

 

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


Kind Regards,
Fábio Antunes 

This widget could not be displayed.

Hi Jeff Turner,

 

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


Kind Regards,
Fábio Antunes 

This widget could not be displayed.

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?

This widget could not be displayed.

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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

526 views 3 19
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