Behaviour, autocomplete system field Components

NewByatl
Contributor
December 9, 2021

Hello! Im trying to make "Create button" ( Fragments+ behaviour fich (Scriptrunner)). I almost done it, but i have no idea how to automate autocomplete components value from context issue, help me to find error pls:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.bc.project.component.ProjectComponent
import static com.atlassian.jira.issue.IssueFieldConstants.*
def issueManager = ComponentAccessor.getIssueManager()
def projectManager = ComponentAccessor.getProjectManager()
def issue = underlyingIssue
if (getBehaviourContextId() in [
    "create-issue-products"]) {
    
    
  def contextIssue = issueManager.getIssueObject(getContextIssueId())
    getFieldById("summary").setFormValue("Created from ${contextIssue.key}")
def links = ["${contextIssue.key}"]
    getFieldById("issuelinks-issues").setFormValue(links)
    getFieldById("issuelinks-linktype").setFormValue("blocks")
def epicLinkCf = customFieldManager.getCustomFieldObjectByName("Epic Link")
def linkedEpic = contextIssue.getCustomFieldValue(epicLinkCf) as Issue
    if(linkedEpic){
        getFieldByName("Epic Link").setFormValue(linkedEpic.key)
    }
    def rodZad = getFieldById("customField_10501").setFormValue(links)
    
    //component script part
def Componentss = contextIssue.getComponents()
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id)
    getFieldById(COMPONENTS).setFormValue(components.findAll { it.name in Componentss }*.id)
    
    
   
}
Снимок экрана 2021-12-09 в 15.43.26.pngСнимок экрана 2021-12-09 в 15.49.06.png

1 answer

1 vote
Bert Dombrecht
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.
January 31, 2022

Hi,

This is what worked for me.
Possibly the issue is in 'getFieldById(COMPONENTS)'.

def contextComponents = contextIssue.getComponents();
if (contextComponents) {
getFieldById("components").setFormValue(contextComponents.findAll {it.name}*.id);
}

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.
September 6, 2024

@Bert Dombrecht its helpfull! Thank you for answer! 

Like Bert Dombrecht likes this

Suggest an answer

Log in or Sign up to answer