Forums

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

Scriptrunner Behaviours - Populate description based on custom field

DL_PGF
Contributor
December 6, 2023

Trying to populate description but my script isn't working. Can someone help?

Custom field is a cascading select list.

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

 

const changedField = getChangeField();

if (changedField.getName() === "customfield_10205") {

const requestName = changedField.getValue().name.toString();

if (requestName === "Project") {
getFieldById("description").setValue({
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "As a ",
"marks": [
{
"type": "strong"
}
]
},
{
"type": "text",
"text": "<type of user>"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "I want ",
"marks": [
{
"type": "strong"
}
]
},
{
"type": "text",
"text": "<to achieve some goal>"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "So that ",
"marks": [
{
"type": "strong"
}
]
},
{
"type": "text",
"text": "<some reason is fulfilled>"
}
]
}
]
})
}

1 answer

0 votes
Kristian Walker _Adaptavist_
Community Champion
December 6, 2023

Hi Derrick,

Thank you for your question.

I can confirm that Cascading select list fields are not supported by Behaviours in Jira Cloud and this will be why your script is not working.

With Behaviours, you can only check the change value of fields supported for the view the script runs on, which you can see documented here.

I hope this information helps.

Regards,

Kristian

DL_PGF
Contributor
December 6, 2023

Thanks @Kristian Walker _Adaptavist_ !

 

I've changed it to single select, but it still doesn't activate in the create issue screen when I choose the dropdown.

Kristian Walker _Adaptavist_
Community Champion
December 7, 2023

HI Derrick,

In your code, you do if (changedField.getName() === "customfield_10205") { however customfield_10205 is the ID so you must put the field name here.

The name of the field is the text shown above the field on the create screen.

Also, in your requestName variable getValue().name is not valid and needs to be getValue().value as shown in the example here

I have tested making these changes to your script, and after this, it works as expected.

Finally, please remember that Behaviours only supports company-managed software and work management projects.

I hope this helps.

Regards,

Kristian

Suggest an answer

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

Atlassian Community Events