${database picker custom field} : getting numeric value not the actual output using this code in template.
Hi @Chandu
Database Picker custom field in a Document Generator template, returns the numeric ID rather than the display value, as you mentioned. To retrieve the label or text value is a bit tricky but I think we can get somewhere using the Groovy script
Let's modify your template to use Groovy for resolving the field:
<#assign customFieldManager = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager() />
<#assign databasePickerField = customFieldManager.getCustomFieldObjectByName("Database Picker Field Name") />
<#assign databasePickerValue = issue.getCustomFieldValue(databasePickerField) />
<#if databasePickerValue??>
${databasePickerValue.displayValue}
<#else>
No value
</#if>
Depending on your database picker configuration, the displayValue
method above may not work. In that case you need to change it accordingly. If you don't know the exact method name, you can list the methods from metaclass and see which one is the right one for you
<#list databasePickerValue.metaClass.methods as method>
${method.name}<br/>
</#list>
Alternatively, you can use a scripted field and reference it in your Document Generator template
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = ComponentAccessor.getIssueManager().getIssueObject(issue.id)
def databasePickerField = customFieldManager.getCustomFieldObjectByName("Database Picker Field Name")
def databasePickerValue = issue.getCustomFieldValue(databasePickerField)
return databasePickerValue?.displayValue ?: "No value"
and this is the document generator template
${customfield_12345}
Hi @Chandu
You can use Jira's upload attachment REST Api for that.
POST /rest/api/3/issue/{issueIdOrKey}/attachments
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Tuncay Senturk,
Thank you for reply.
Actually it is Database Picker Field and I want to export it using document generator.
can you please tell me normal cusrom field will export using ${custom field} this small code but for "database picker custom field", this code is not working . do you have any workaround to export the database picker custom field or any code to export it using document generator template.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, this was an answer to another post. Somehow, I wrote it here :) you can see my actual answer above.
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.