Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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

Suggest an answer

Log in or Sign up to answer

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

new.jpg

0 votes
Thanos Batagiannis [Adaptavist]
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 25, 2018

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

TAGS
AUG Leaders

Atlassian Community Events