Hi,
On some transition I need to create a new issue and link it to current.
issue is creating, but have faced with a little problem - I dont know how to take an issue key of this new created one. this code links current issue with itself, not a new one.
could you help me please?
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue; //to take current issue id Issue issue = issue def id=issue.getId() //***rest code*** issueInputParameters.with { projectId = projectManager.getProjectObjByKey("SD").id summary = "test" issueTypeId = issueType.getId() description = "test" Project project = projectManager.getProjectObj(projectId) def projectlead=project.getLeadUserName() reporterId = projectlead } def validationResult = issueService.validateCreate(user, issueInputParameters) assert !validationResult.errorCollection.hasAnyErrors() def issueResult = issueService.create(user, validationResult) //to take created issue id def newid=issue.getId() def issueLinkManager = ComponentAccessor.getIssueLinkManager(); issueLinkManager.createIssueLink(newid, id, Long.parseLong("10003"),Long.valueOf(1), user);
Hi Saida,
You can get the newly created issue via IssueValidationResult
def issueResult = issueService.create(user, validationResult) def newIssue = issueResult.getIssue()
can you please explain me why it is returns
ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: SD-6574, actionId: 1031, file: <inline script> groovy.lang.MissingPropertyException: No such property: customFieldManager for class: Script424 at Script424.run(Script424.groovy:12)
when I change it like this?
import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField CustomField incAffect = customFieldManager.getCustomFieldObject(new Long(10703)); String curIncAffect = issue.getCustomFieldValue(incAffect); if (issue.issueTypeObject.name == "Incident" && (curIncAffect == "Group of branches" || curIncAffect == "Bank" || curIncAffect == "Branch")) { // code }
incAffect is a single select list cf
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
or if
if (issue.issueTypeObject.name == "Incident" && (cfValues['Incident Affected']?.getValue() == "Group of branches" || cfValues['Incident Affected']?.getValue() == "Bank" || cfValues['Incident Affected']?.getValue() == "Branch")) { // code }
it returns :
2016-08-01 17:50:55,681 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: SD-6574, actionId: 1031, file: <inline script> groovy.lang.MissingPropertyException: No such property: cfValues for class: Script441 at Script441.run(Script441.groovy:17)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to call the customFieldManager
import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager() // also you can get the custom filed by name instead of a long id def incAffect = customFieldManager.getCustomFieldObjectByName("Inc Affect CustomField Name")
I think you asked another related AA question and the issue was that you were getting the customFieldManager but there was a typo...
regards
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.