Using Jira Software DC 8.21.1 with Jira Advance Roadmaps and ScriptRunner DC 6.47.0, I'm trying to auto copy a Jira custom field of "IT Team" to Jira Roadmaps "Team" field when ever the Jira custom field "IT Team" gets updated. I was thinking of using Behaviors to keep both fields in sync at all times, but it seems that this "Team" field for Jira Roadmaps only accepts value IDs.
What is the best way to copy the field value once the Jira Custom Field of "IT Team" is selected as "Fun Team1", which needs to copy the equivalate field value ID of "11" to the Jira Roadmaps field "Team" which only accepts IDs? I'm looking for help with the groovy script that would address this with Behaviors.
Appreciating You!
It would be better to use the Listener for your requirement instead of the Behaviour.
Could you please provide more information, i.e. what type of field are you using for IT Team?
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_
That would make sense since I can use Issue Created and Issue Updated events to trigger the script that I need help with. I'm using a Select List (multiple choices) for the "IT Team" field. Please Note: their would normally only be one team/value selected. The reason its multi-select is for Features Epics that span multiple teams.
Appreciating You and Thanks!
Luis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For your requirement, you could try something like this:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def issue = event.issue as MutableIssue
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def sampleMultiSelect = customFieldManager.getCustomFieldObjectsByName('Sample Multi Select').first()
def sampleMultiSelectValue = sampleMultiSelect.getValue(issue) as String
def selectedOption = customFieldManager.getCustomFieldObjectsByName('Selected Option').first()
issue.setCustomFieldValue(selectedOption, sampleMultiSelectValue)
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.ISSUE_UPDATED, false)
Please note that the sample working code above is not 100% exact to your environment. Hence you will need to make the required modifications.
You will need to use the Custom Listener and set the IssueCreated and IssueUpdated events for the Listener configuration.
Below is a print screen of the Listener configuration:-
The Issue Created event and Issue Updated event have been selected in this example. So the listener will trigger during the creation of an Issue and when the Issue is edited.
Below are a few test print screens for your reference:-
1. In the first test, a ticket is created, but no option has been selected in the Sample Multi Select field. Hence, no value is displayed on the Issue when it is first created, as shown in the image below.
Similarly, there is no value added to the Selected Options field in the Roadmap.
2. Next, the Issue is updated, and an option is selected from the Sample Multi Select list, as shown in the image below.
Accordingly, the field is now visible in the ticket. Also, the Selected Options field is visible.
Finally, if you now check the Roadmaps page, it will display the updated value for the Selected Options field.
I hope this helps to solve your question. :)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.