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

How to copy value of "organization" CF to non servicedesk project

Lukáš Krajči January 15, 2020

Hi I am trying to copy organization field value to another CF in linked issue. I have some scriptrunner script and I tried to hook it on "Create issue" transition, but it is not working, any suggestions please? We have only scriptrunner.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.user.ApplicationUser
def cfm = ComponentAccessor.getCustomFieldManager()

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
MutableIssue parent = issue
List<IssueLink> vykazovanieLinks = ComponentAccessor.getIssueLinkManager().getOutwardLinks(parent.getId()).findAll{it.getIssueLinkType().getName().equals("Vykazovanie")}

if (vykazovanieLinks) {
Issue linkedIssue = vykazovanieLinks.find{it.getDestinationObject().getProjectObject().getKey().equals("DRGSD")}?.getDestinationObject()
log.debug('linkedIssue: ' + linkedIssue)
if (linkedIssue){
CustomField organizations = cfm.getCustomFieldObjectsByName("Organizations").getAt(0)
CustomField organizations_int = cfm.getCustomFieldObjectsByName("Zadané v mene").getAt(0)
log.debug('Organizations ' + organizations)
parent.setCustomFieldValue(organizations_int, organizations)
ComponentAccessor.getIssueManager().updateIssue(currentUser, parent, EventDispatchOption.ISSUE_UPDATED, false)
}
}

 

1 answer

0 votes
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 4, 2020

Hi @Lukáš Krajči ,

did you succeed in resolving this issue? I can see that the problem is probably in the line:

parent.setCustomFieldValue(organizations_int, organizations)

The second variable "organizations" should be the new value of the custom field, but you have stored only the custom field itself, not it's value.

Which type does "Zadané v mene" custom field have? Is it a text field? Thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events