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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Need to copy the assignee field to developer field in a transition screen.

Hi,

i wanted set the Developer field values as same in assignee field in a transition screen.

I've tried with Groovy script ( set field value ) on post function.

Below is the code snip:

 

if(issue.getIssueTypeObject().getName()=="Bug")
{
issue.get("assignee")?.getName()
}

it complies without any error but the screen doesn't showing the expected result.

Any suggestions on this ? 

1 answer

1 accepted

0 votes
Answer accepted

You don't appear to be using a set in your code.  When you do, https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/postfunctions/set-issue-attributes.html is a good bookmark for sample code.

Thanks for the Reply @Nic Brough _Adaptavist_ , i've one more query i.e whether the first code in the above link will work for copying value from system field to system field ?

below is my current configuration:

1.JPG2.JPG

Broadly, yes, I think you can see how to use other fields in there.

I've tried with setCustomFieldValue seems something missing. i have added my code below. can you have a look on it ?developer.JPG 

its returning Null, but the assignee field is not empty for the case I've tested with.

The result is what the script returns.  You have no return value at the end, so it's coming out with null.

I think you need to return either the assignee or the current value of the field (so it doesn't replace it with null)

@Nic Brough _Adaptavist_ Thank you :) That really worked well. 

below is the final code :

import com.atlassian.jira.*
import com.atlassian.jira.user.*
import com.atlassian.jira.component.ComponentAccessor

def userUtil = ComponentAccessor.getUserUtil()
if (issue.issueTypeObject.name == "Bug")
{
issue.setAssignee(userUtil.getUserByName("User Name"))
return (issue.get("fieldA").getName())
issue.store()
}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

Share your Confluence Cloud experience for a chance to win $500!

Take our 5-minute survey to win a $500 Visa gift card! Are you currently using Confluence Cloud? We want to hear from you! Fill out this quick survey about your Confluence Cloud experience so we ...

293 views 5 14
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you