${database picker custom field} : getting numeric value not the actual output using this code in template.
Hi @Chandu
You can use Jira's upload attachment REST Api for that.
POST /rest/api/3/issue/{issueIdOrKey}/attachments
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post
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.
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
displayValue
<#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.ComponentAccessordef 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}
Sorry, this was an answer to another post. Somehow, I wrote it here you can see my actual answer above.
It looks like you're new here. Sign in or register to get started.