Hi,
I Need to copy the custom field values from existing issue to newly created issues only if I have selected same option in both the issues of select list custom field and both issues will have different issue types.
Example:
API Name is select list field. In that using one option " Agent Login" I have created one issue and the issue type is New requirement.
Now I want to create another issue with Onboarding issue type and the API name is "Agent Login", this time newly created issue has to fetch the custom field values from existing issue i.e; New Requirement Issue type Issue.
Please let me know how to achieve this functionality in JIRA Server.
We are using Automation for JIRA and script runner addon's.
Thanks for your help in advance!
Thanks,
Lakshmi.
Issue issue = event.issue // Newly created issue Object
def jqlSearch = /"/+type+/" ~ '/+issue.key+/'/
//Define the JQL to find existing issue to match your criteria for ex ( issuetype != newly created issue and custom field = <select custom field value>
//def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def userManager=ComponentAccessor.getUserManager()
ApplicationUser user = userManager.getUserByName('jiraservice')
def searchService = ComponentAccessor.getComponentOfType(SearchService.class)
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
def issues=''
def results = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = results.getResults() // Existing Issue which match the criteria.
issues.each{foundIssue-> //Itrerate the issues
copyvalue(foundIssue, user, 10301L) // call function to copy the value from existing issues to newly created issue
}
void copyvalue(Issue issue, def ApplicationUser user, Long eventId) {
//write code to take value from exiting issue and update to the newly created issue
}
This is the sample code which you need to modify like i mentioned.
Accept the answer if it helps
Yes you can copy the values of custom field from other issues provided they have link between them.
If not then you need to write the custom script which will check the related issues based on the select list values and then copy the custom field value from that issue whenever new issue has been created (On Create Listener)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.