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)
}
}
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.