Hi all,
I'm currently stuck with this request:
A bit of background: we have one main project, and many smaller local projects in Jira. The Story handover procedure is when a story in a local project is moved to In progress, it will be cloned to the main project by a post function.
The local project story is depending on the main project story, the main project story is contributing to the local project story (link type).
Now my question: in the story screen of the local projects, there is one field that the story screen of the main project didn't have. But now, I added this field to the story screen of the main project. The users actually want the values of this field of the existing stories of the main project will reflect the values of it in local project.
I'm not sure how we should do this.
I tried use Built-in Script of Script runner, no hope. I try to write JQL to bulk change them, no hope because I'm sure how to find isses that are contributing to certain issues.
Can you please help me out here?
Thank you!
Just to make sure I understand correctly. You have a post-function as of now that clones an issue into another project which works fine. Now you need the cloned issue to copy over a new field value that was only present on the story of the local project before right?
I dont know for sure, but I am pretty sure that field values are retained when you clone an issue. I would check the screens of the target issuetype, to make sure the field is there. One way you could check is to go to a cloned issue and click Admin -> Where is my field?
Let me know what you find :)
Thank you for your answer!
The thing is, the field was not in the screen of the main project before, and now it was added to its screen. During the time of it not being in the screen of the main project, there was a number of stories being cloned from local to the main project, and as the field was not there, the was no value for the stories in the main project at all. And the field does not show anything now in the stories, which were cloned before the field was enabled.
That's why I want to copy the values.
Best,
Duong
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem! :)
Shouldn't be an issue. You can definitely do this is Scriptrunner. I would recommend doing it in the Console as this seems like a one-time thing :)
The approach would be something like:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.query.Query
import org.apache.log4j.Logger
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
def searchService = ComponentAccessor.getComponent(SearchService.class)
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def customFieldManager = ComponentAccessor.customFieldManager
def userManager = ComponentAccessor.userManager
def issueManager = ComponentAccessor.issueManager
def issueService = ComponentAccessor.issueService
def user = userManager.getUserByName("admin")
def query = jqlQueryParser.parseQuery("assignee = currentUser()")
def results = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
results.getResults().each { issue ->
def issueResult = issueManager.getIssueObject(issue.id)
log.info(issueResult)
def sourceField = customFieldManager.getCustomFieldObject("customfield_XXXXXX")
def sourceFieldValue = sourceField.getValue(issueResult)
def targetField = customFieldManager.getCustomFieldObject("customfield_XXXXXX")
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.addCustomFieldValue(targetField, sourceFieldValue)
def validationResult = issueService.validateUpdate(user, issueResult.id, issueInputParameters)
if (validationResult.isValid()) {
issueService.update(user, validationResult)
} else {
validationResult.getErrorCollection().getErrorMessages()
}
}
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.