Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve the value from a multi-line Text field custom field in Jira Cloud using ScriptRunner

Kent Chiu
Contributor
August 28, 2023

Hi,

How do we retrieve the value of a multi-line text custom field using ScriptRunner?

I have been having difficulties retrieving the value from a multi-line text custom field.  The code that I have used before does not work for the multi-line:

------------------------------------------------------------------------------------------------

def issueKey = issue.key


// Fetch the issue object from the key
def issue = get("/rest/api/3/issue/${issueKey}")
.header('Content-Type', 'application/json')
.asObject(Map)
.body

// Get all the fields from the issue as a Map
def fields = issue.fields as Map

// Get the Custom field to get the option value from 
def component = get("/rest/api/3/field")
.asObject(List)
.body
.find {
(it as Map).name == 'Component(s)'
} as Map

assert component : "Failed to find custom field with given name"
// Extract and store the option from the custom field
def component_value = (fields[compoent.id])?.value

I see the cutom field record in the fields query:

"customfield_10119": {
"type": "doc",
"version": 1,
"content": [
      {
           "type": "paragraph",
            "content": [
                       {
                              "type": "text",
                                "text": "MV Release 1234"
                       }
               ]
        }
   ]
},

---------------------------------------------------------------------------------------

I appreciate your help.

Thanks,

--Kent

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events