We are using a bundled field on a request form and would like to export the field contents as a csv so each sub-field is a seperate line or column in the file.
We would also like to attach the csv to the JSD ticket.
Any help is appreciated.
We are using Extention for Jira Service Desk and we have Scriptrunner also.
https://deviniti.com/support/addon/server/extension/latest/bundled-fields/
I ended up writing a Scriptrunner script to make this work. The script runs as part of an automation that works with the issue. It isn't great code, but it works for me.
Here are some other threads I reference to build my code.
get Data:https://deviniti.com/support/addon/server/dynamic-forms/latest/bundled-fields-script-runner/#get-bundled-field-s-valuewrite to file:https://community.atlassian.com/t5/Jira-Questions/Script-Runner-file-writing/qaq-p/706075attach file:https://community.atlassian.com/t5/Jira-Questions/Help-me-to-add-attachment-automatically-when-issue-has-been/qaq-p/1042875
import com.atlassian.jira.component.ComponentAccessorimport groovy.json.JsonSlurperimport org.apache.log4j.Loggerimport org.apache.log4j.Levelimport org.apache.http.entity.ContentTypeimport groovy.json.StreamingJsonBuilderimport org.apache.http.entity.ContentTypeimport com.atlassian.jira.issue.comments.CommentManagerimport groovy.json.JsonOutputimport com.atlassian.jira.issue.*import com.atlassian.jira.issue.attachment.*import webwork.action.ActionContext//create File to store datainFile file = new File("/home/jira/RPA New Process Details.csv")//key of issue, where the bundledfields value isString issueKey = issue.key//id of bundledfield where we are looking for valueString bundledFieldId= "customfield_14200" //rpa new process details field//row in bundledfieldInteger row = 0def issueManager = ComponentAccessor.getIssueManager()def customFieldManager = ComponentAccessor.getCustomFieldManager()def cfBundledFields = customFieldManager.getCustomFieldObject(bundledFieldId)def thisIssue = issueManager.getIssueObject(issueKey)def attachmentManager = ComponentAccessor.getAttachmentManager()def user = ComponentAccessor.getJiraAuthenticationContext()?.getLoggedInUser()String cfValue = issue.getCustomFieldValue(cfBundledFields)Object jsonValue = new JsonSlurper().parseText(cfValue)//first field column in bundledfieldString fieldName = "Department"//grab each field value and store in variablesdef department = getValue(fieldName, row, jsonValue)fieldName = "Name of Process"def processName = getValue(fieldName, row, jsonValue)fieldName = "Description of Process to be Automated"def processDescription = getValue(fieldName, row, jsonValue)fieldName = "Corporate Priorities Alignment (Check all that apply)"def priorities = getValue(fieldName, row, jsonValue)fieldName = "Systems Impacted (List all that apply, Outlook, Access Point, Mapper, CLMS, etc.)"def impactedSystems = getValue(fieldName, row, jsonValue)fieldName = "Is process highly manual and repetitive?"def manual = getValue(fieldName, row, jsonValue)fieldName = "Is data in electronic format?"def electronic = getValue(fieldName, row, jsonValue)fieldName = "Is the process rules driven?"def rules = getValue(fieldName, row, jsonValue)fieldName = "Are there many exceptions to the process?"def exceptions = getValue(fieldName, row, jsonValue)fieldName = "Is there a high process volume?"def volume = getValue(fieldName, row, jsonValue)fieldName = "Any planned changes to this process workflow or technical systems it uses?"def plannedChanges = getValue(fieldName, row, jsonValue)fieldName = "If yes, when are these changes expected?"def changesExpected = getValue(fieldName, row, jsonValue)fieldName = "How does automating this process help team members do their jobs better?"def helpTeam = getValue(fieldName, row, jsonValue)fieldName = "Is there a deadline for this BOT to be in production?"def deadline = getValue(fieldName, row, jsonValue)fieldName = "If there is a deadline, what are the factors that are impacting this deadline?"def impactDeadline = getValue(fieldName, row, jsonValue)fieldName = "What is the expected life for the BOT? (Is this short term, long term, etc.)"def expectedLife = getValue(fieldName, row, jsonValue)// write to the csv filefile.write "Department,"+department+",Name of Process,"+processName+",Description of Process to be Automated,"+processDescription+",Corporate Priorities Alignment (Check all that apply),"+priorities+",Systems Impacted (List all that apply),"+impactedSystems+",Is process highly manual and repetitive?,"+manual+",Is data in electronic format?,"+electronic+",Is the process rules driven?,"+rules+",Are there many exceptions to the process?,"+exceptions+",Is there a high process volume?,"+volume+",Any planned changes to this process workflow or technical systems it uses?,"+plannedChanges+",If yes when are these changes expected?,"+changesExpected+",How does automating this process help team members do their jobs better?,"+helpTeam+",Is there a deadline for this BOT to be in production?,"+deadline+",If there is a deadline what are the factors that are impacting this deadline?,"+impactDeadline+",What is the expected life for the BOT?,"+expectedLife// build attachmentdef bean = new CreateAttachmentParamsBean.Builder().file(new File("home/jira/RPA New Process Details.csv")).filename("RPA New Process Details.csv").contentType("csv").author(user).issue(thisIssue).build()// attach file to tickettry{attachmentManager.createAttachment(bean)}catch(AttachmentException){}////Methods below are used to Retrieve a value of requested row and field namedef String getValue(fieldName, row, jsonValue) {List fields = getFieldsForRow(row,(Map) jsonValue)Map field = getFieldByName(fieldName,fields)def value = getFieldValue(field)return value}def String getFieldValue(Map field){def type = field.typeif(type == 'select' || type == 'checkbox'){return getOptionValue(field)}return field.value}def String getOptionValue(Map field) {List<Map> allOptions = (List<Map>) field.optionsString val = field.valueString[] selectedIds = val.split(',')List<Map> selectedOptions = allOptions.findAll { it.id in selectedIds }return selectedOptions.name.join(', ')}def Map getFieldByName(fieldName, List<Map> fields){return fields.find{it.name == fieldName}}def List getFieldsForRow(row,Map json){List fields = nullint i=0json.each{k,v -> if(i == row){fields = ((Map) v).get("fields")}i++}return fields}
The
I am trying to find a solution as well, but don't have anything yet. The bundled field has the values stored in there, so trying to see if there is a way to use a script (or other add-on) that could automatically populate another set of fields (hidden from user) that can be used for an export. That is my approach but do not have a solution yet.
Below is the beginning of a bundled field value string, just for the first element. I bolded the field name and value that I would try to parse out, with the field name being the target hidden field, and the value the populated data.
So trying to get the best of both - a bundled field for the UI, and a separate field for the data to export,
{"baseGroupId":{"fields":[{"id":"bd85005b-5e3d-485f-9df7-a9e8c8f8490f","originId":"bd85005b-5e3d-485f-9df7-a9e8c8f8490f","name":"OE#1","type":"text","required":false,"options":[],"showLabel":false,"dateType":false,"selectableType":false,"isValid":true,"valuePreview":"AQ123","value":"AQ123"},
We'll see if this is possible.
It looks like you're new here. Sign in or register to get started.