Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy Organizations to custom field

Berry Kersten
Contributor
September 29, 2020

Current situation:

ScriptRunner Post function 'Clones an issue, and links' used for cloning an issue from project X to project Y

Wish

Copy the field Organizations in JSD project X to custom field Reported Organization in project Y

Current implementation

The solution must be something like this

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Reported Organization'}
issue.setCustomFieldValue(sourceIssue.(Organizations)

However, I'm getting an error:

Script305.groovy: 4: unexpected token:  @ line 4, column 54.
   ue(sourceIssue.(Organizations)

Ideas anyone? Thanks.

2 answers

Suggest an answer

Log in or Sign up to answer
1 vote
John Chin
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 Champions.
January 24, 2021

Hi @Linton Tomaz da Silva ,

issue.reporter method is returning an ApplicationUser value so the comparison with String value might not be working.

Please try this way and I can confirm is working on my side:

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

def userManager = ComponentAccessor.userManager

ApplicationUser user = userManager.getUserByName("Cybersecurity.telefonica")

user == issue.reporter

 I hope this helps :)

Linton Tomaz da Silva
January 26, 2021

Hi @John Chin 

The scriptrunner continues to send e-mail in all situations, the condition is ignored, I need the e-mail to be sent only when reporter == 'Cybersecurity.telefonica', did not work.

John Chin
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 Champions.
January 26, 2021

As I mentioned, please use this script on the scriptrunner condition:

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

def userManager = ComponentAccessor.userManager

ApplicationUser user = userManager.getUserByName("Cybersecurity.telefonica")

user == issue.reporter
0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
January 22, 2021

Hi @Linton Tomaz da Silva can you share screenshot of your configuration pls?

Linton Tomaz da Silva
January 26, 2021

Hi @Martin Bayer _MoroSystems_ s_r_o__  follow the captured screens.image.pngimage.pngimage.png

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
January 26, 2021

Thank you for the screenshots... it looks good so far. What if you press "preview"? What is the result? There should be information about condition and if it was true or false.

Linton Tomaz da Silva
January 26, 2021

Hi, when clicking on preview the displayed message is correct, see



Linton Tomaz da Silva
January 26, 2021

.

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
January 26, 2021

@Linton Tomaz da Silva it looks like attachment/screenshot was not uploaded.

Linton Tomaz da Silva
January 26, 2021

this is the imagimage.png

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
January 26, 2021

Ok, are you sure you Published your workflow? It is not enought to Save the postfunction's configuration. You also need to publish the workflow.

TAGS
AUG Leaders

Atlassian Community Events