Hello, community!
(JIRA 6.1.7)
I try to get value from customfield and copy value of it to autocreated linked issue:
customLaborCosts = cfm.getCustomFieldObject("customfield_10901") issueObject.setOriginalEstimate(customLaborCosts.getValue(issue));
Customfield_10901 it is a text field, so i imagine that it is a string object. In the desscription of setOriginalEstimate i see two variants (for Long and for String).
But when i try to call script then it return:
root cause: Traceback (most recent call last): File "e:\jira\jira617wd\jss\jython\workflow\createLinkedIssue.jy", line 57, in <module> issueObject.setOriginalEstimate(customLaborCosts.getValue(issue)); TypeError: setOriginalEstimate(): 1st arg can't be coerced to java.lang.Long
How can i copy value to new issue? The other functions are working fine.
The entire script listing is:
# -*- coding: UTF-8 -*- from com.atlassian.jira.util import ImportUtils from com.atlassian.jira import ManagerFactory from com.atlassian.jira.issue import MutableIssue from com.atlassian.jira import ComponentManager from com.atlassian.jira.issue.link import DefaultIssueLinkManager from org.ofbiz.core.entity import GenericValue; from com.atlassian.jira.issue.fields import CustomField #from java.util import Locale from com.atlassian.jira.issue import CustomFieldManager from sys import exit if (issue.getIssueTypeId() != "10000" and issue.getIssueTypeId() != "7" and issue.getIssueTypeObject().getName() != "Request"): # get issue objects issueManager = ComponentManager.getInstance().getIssueManager() issueLinkManager = ComponentManager.getInstance().getIssueLinkManager() issueFactory = ComponentManager.getInstance().getIssueFactory() authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext() #subTaskManager = ComponentManager.getInstance().getSubTaskManager(); issueLinkManager = ComponentManager.getInstance().getIssueLinkManager() customFieldManager = ComponentManager.getInstance().getCustomFieldManager() userUtil = ComponentManager.getInstance().getUserUtil() cfm = ComponentManager.getInstance().getCustomFieldManager() customUserField = cfm.getCustomFieldObject("customfield_10403") testerFieldValue = issue.getCustomFieldValue(customUserField) customEpicField = cfm.getCustomFieldObject("customfield_10001") componentFieldValue = issue.getComponentObjects() labelsFieldValue = issue.getLabels() customLaborCosts = cfm.getCustomFieldObject("customfield_10901") # define subtask #issueObject = issueFactory.getIssue() #issueObject.setProject(issue.getProject()) #issueObject.setIssueTypeId("1") # normal subtask #issueObject.setParentId(issue.getId()) #define linked issue issueObject = issueFactory.getIssue() issueObject.setProject(issue.getProject()) issueObject.setIssueTypeId("10000") # issue type Test issueObject.setParentId(issue.getId()) # set subtask attributes issueObject.setFixVersions(issue.getFixVersions()) issueObject.setAffectedVersions(issue.getAffectedVersions()) issueObject.setPriority(issue.getPriority()) #issueObject.setSummary("Auto created sub task- "+issue.getSummary()) #issueObject.setSummary("Тестировать - "+issue.getKey().replace("-","--")) issueObject.setSummary("Тестировать - "+issue.getKey()+"/"+issue.getSummary()) issueObject.setCustomFieldValue(customEpicField, customEpicField.getValue(issue)); issueObject.setComponentObjects(componentFieldValue) issueObject.setLabels(labelsFieldValue) issueObject.setOriginalEstimate(customLaborCosts.getValue(issue)); listLinkIssue = issueLinkManager.getLinkCollectionOverrideSecurity(issue).getAllIssues() for issueLink in listLinkIssue: #log.info("Linked Issue: " + issueLink.getKey() + " " + issueLink.getIssueTypeObject().getName()) if (issueLink.getIssueTypeObject().getName() == "Story"): issueObject.setDescription(issueLink.getKey() + " "); #issueObject.setAssignee(userUtil.getUserObject("joe")) if (not (testerFieldValue is None)): tester = userUtil.getUserObject(testerFieldValue.getUsername()) issueObject.setAssignee(tester) issueObject.setReporter(authenticationContext.getLoggedInUser()) # Create subtask on JIRA 4.x # subTask = issueManager.createIssue(authenticationContext.getUser(), issueObject) # subTaskManager.createSubTaskIssueLink(issue.getGenericValue(), subTask, authenticationContext.getUser()) # Create subtask on JIRA 5 and higher #subTask = issueManager.createIssueObject(authenticationContext.getLoggedInUser(), issueObject) #subTaskManager.createSubTaskIssueLink(issue, subTask, authenticationContext.getLoggedInUser()) # Create linktask on JIRA 5 and higher linkTask = issueManager.createIssueObject(authenticationContext.getLoggedInUser(), issueObject) #issueManager.createSubTaskIssueLink(issue, subTask, authenticationContext.getLoggedInUser()) # Link parent issue to subtask #issueLinkManager.createIssueLink(issue.getId(),issueObject.getId(),10003,1,issue.getAssignee()) # Update search indexes wasIndexing = ImportUtils.isIndexIssues() ImportUtils.setIndexIssues(True) ComponentManager.getInstance().getIndexManager().reIndex(linkTask) ImportUtils.setIndexIssues(wasIndexing)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.