No errors but script not updating/copying components from custom components field (customfield_15961) to system components field any help appreciated
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.Project
def log = Logger.getLogger("com.acme.workflows")
log.setLevel(Level.DEBUG)
log.warn("Workflow function running...")
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// edit this query to suit
def query = jqlQueryParser.parseQuery("project = XZ AND issuekey in (XZ-25361,XZ-25345,XZ-24982)")
def search = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
log.debug("Total issues: ${search.total}")
search.results.each { documentIssue ->
def issue = issueManager.getIssueObject(documentIssue.id)
log.debug(issue.key)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject('customfield_159604');
def compName = issue.getCustomFieldValue(customField)
log.debug(compName)
def issueService = ComponentAccessor.getIssueService()
def issueInputParameters = issueService.newIssueInputParameters()
def componentManager = ComponentAccessor.projectComponentManager
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
//issueInputParameters.setcomponent(compName); //copy story description to description
Project project = issue.getProjectObject()
String compName2=compName.toString() //converting to string to pass to projectComponentManager.findByComponentName
def ComponentValue = projectComponentManager.findByComponentName(project.getId(), compName2)
if (ComponentValue) {
log.debug(ComponentValue)
issue.setComponent([ComponentValue])
}
}
help me to make this script updates system component field
i.e I would like to copy "Unknown" value from custom components field (customfield_15961) to system components field (where system comp having ""Unknown" value) but its not working.