Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,365,548
Community Members
 
Community Events
168
Community Groups

Adaptavist: groovy behaviour script to fill fields on creation form (from context issue)

Hi Guys,

My behaviour script is set values to fields on creation issue form.

I faced with problem: Assignee field is empty (unassigned) after creation.

What i missed?


My Script:

import com.onresolve.jira.groovy.user.FieldBehaviours
import static com.atlassian.jira.issue.IssueFieldConstants.*
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser

def issueManager = ComponentAccessor.getIssueManager()
def contextIssue = issueManager.getIssueObject(getContextIssueId())
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def epicLinkCf = customFieldManager.getCustomFieldObjectByName("Epic Link")
def linkedEpic = contextIssue.getCustomFieldValue(epicLinkCf) as Issue
def assignee = getFieldById("assignee-field")

def developer = customFieldManager.getCustomFieldObjectByName("Developer")
def user = contextIssue.getCustomFieldValue(developer) as ApplicationUser


if (getBehaviourContextId() == "link-create-blocking") {
getFieldById("project-field").setReadOnly(true)
getFieldById("issuetype-field").setReadOnly(true)
getFieldById("issuelinks-linktype").setFormValue("Linked to Testing").setReadOnly(true)
getFieldById("issuelinks-issues").setFormValue(contextIssue.key).setReadOnly(true)
getFieldByName("Epic Link").setFormValue(linkedEpic.key).setReadOnly(true)
if ((user) != null)
{
assignee.setFormValue(user.displayName)setReadOnly(false)
}
}

 Snapshots:
script.jpg

2 answers

Hi Thanos,
Your solution does not works: now assignee field does not populate on creation form,
PFA:

new.jpg

Hi Сергей,

The id of the assignee field is wrong, and since you already import the IssueFieldConstants (good practice) then 

def assignee = getFieldById(ASSIGNEE)

Regards, Thanos

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events