How can I automatically pre-fill fields on the “Create an issue in an epic” screen?

Alex
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2024

Hi, community! 

Tell me how can I implement pre-filling fields with values ​​from the epic when creating a “task in the epic”?

As I understand it, the best solution would be "Behavior"? Or maybe there are some ready-made solutions?

create screen.png

Any help is important. Thank you!

Best regards, Alex!

3 answers

1 accepted

0 votes
Answer accepted
Alex
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 16, 2024

i.e. how the process occurs On your “task in epic” creation screen, you should add a “Link to epic” field, in which you set your task epic, from which the fields on this screen will then be pulled up.

Solution . My Code for Behavior :

in frame "field"

import java.text.SimpleDateFormat
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue

def setFieldValueIfNotNull(String fieldName, Object value) {

if (value!= null) {

def customField = getFieldByName(fieldName)

if (customField!= null) {

customField.setFormValue(value)

} else {

log.warn("$fieldName not found")

}

} else {

log.warn("$fieldName not set or value empty")

}

}

def cf_link_on_epic_value = getFieldByName('Link on epic').value

if (cf_link_on_epic_value!= null) {

String epic_value = cf_link_on_epic_value

def parts = epic_value.split(':')

def epicKey = parts[1].trim()

def issueManager = ComponentAccessor.getIssueManager()

def epicIssue = issueManager.getIssueObject(epicKey)

def customFieldManager = ComponentAccessor.getCustomFieldManager()

//Next , your cf fields

/
// CF - "Target start"

def epic_TS = epicIssue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Target start"))

setFieldValueIfNotNull('Target start', epic_TS!= null? formatDate(epic_TS) : null)

// CF - "Target end"

def epic_TE = epicIssue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Target end"))

setFieldValueIfNotNull('Target end', epic_TE!= null? formatDate(epic_TE) : null)


} else {

log.warn("link on epic not set or value empty")

}






///////////////////////////////// !add this part ,if only your cffield datetime, else - delete this

// Function for formatted date

def formatDate(Date date) {

SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yy")

return sdf.format(date)

}

1.png2.png
3.png

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 5, 2024

Hi Alex,

Behaviours is the only one I know of that can do something like this. Many of the Marketplace vendors solutions are around forms, so not sure if they can/do connect to Jira Software projects. 

0 votes
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 2, 2024

@Alex, there is not a great out of the box solution for this. If you have custom fields which only apply to epics, you could use default values, but that is likely a limited use case.

 

You'll need to install and configure a plugin. ScriptRunner is one option, but there are numerous other template plugins out there which could also potentially solve your issue. I ran a search in the marketplace and found several potential options.

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events