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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

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

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

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 Nov 04, 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
Community showcase
Published in Jira Service Management

Why upgrade to Jira Service Management Premium?

We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan.  &nb...

196 views 1 6
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