Script in behaviours + fragments.

NewByatl
Contributor
April 25, 2022

I'm trying to upgrade this script, and make it copy assignee and labels, but it still no result, could you help me to find an error in script? Thank you

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.web.util.OutlookDate
import com.atlassian.jira.web.util.OutlookDateManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import java.sql.Timestamp
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS
import static com.atlassian.jira.issue.IssueFieldConstants.LABELS
import static com.atlassian.jira.issue.IssueFieldConstants.ASSIGNEE
def issueManager = ComponentAccessor.getIssueManager()
if (getBehaviourContextId() in [
    "strat-link-create-keyresult"]) {
    getFieldById("project-field").setReadOnly(true)
    getFieldById("issuetype-field").setReadOnly(true)
    def lab = getFieldById("labels")
    getFieldById("assignee").setRequired(true)
    
    def contextIssue = issueManager.getIssueObject(getContextIssueId())
    //getFieldById("summary").setFormValue("This issue from ${contextIssue.key}")
    
    def links = ["${contextIssue.key}"]
    def componentValueClone = contextIssue.getComponentObjects().name
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id)
    getFieldById(COMPONENTS).setFormValue(components.findAll { it.name in componentValueClone }*.id)
    getFieldById("issuelinks-issues").setFormValue(links).setReadOnly(true).setRequired(true)
    getFieldById("issuelinks-linktype").setFormValue("Child").setReadOnly(true)
   
    getFieldById(LABELS).setFormValue(parentIssue.labels)
    getFieldById(ASSIGNEE).setFormValue(parentIssue.assigneeId)
}

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 26, 2022

Hi @NewByatl

Can you provide a little more information, i.e. when do you want the Behaviour to take effect? Is it on a Create, Edit or Transition screen? Could you please share a screenshot?

Also, could you please share a screenshot of the current Behaviour configuration you are using?

Thank you and Kind regards,

Ram

NewByatl
Contributor
April 27, 2022

Create ScreenScreenshot 2022-04-27 at 11.44.23.pngScreenshot 2022-04-27 at 11.45.10.pngScreenshot 2022-04-27 at 11.43.17.pngScreenshot 2022-04-27 at 11.45.36.pngScreenshot 2022-04-27 at 11.43.35.png

NewByatl
Contributor
April 27, 2022

sorry for chaos with screens, it attached in random way( i hope u ll figure out

1. Fragment, which creates button

2. beahviour part 1

3. Create button in issue

4. behaviour part 2

5. how it works now

NewByatl
Contributor
April 27, 2022

Suggest an answer

Log in or Sign up to answer