I copy the following copy from adaptavist library:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.Issue
// the name of the field to copy
final String fieldNameToCopy = "Priority";
// leave blank to copy from the last linked issue (regardless the link type)
final String issueLinkTypeName = "Blocks"
def fieldManager = ComponentAccessor.fieldManager
def fieldToCopy = fieldManager.allAvailableNavigableFields.find { it.name == fieldNameToCopy }
if (!fieldToCopy) {
log.info "Could not find field with name $fieldNameToCopy"
return
}
def linkedIssues = ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id)
if (!linkedIssues) {
log.info "There are no linked issues"
return
}
if (issueLinkTypeName && !(issueLinkTypeName in linkedIssues*.issueLinkType*.name)) {
log.info "Could not find any issue, linked with the $issueLinkTypeName issue type"
return
}
def linkedIssue = issueLinkTypeName ?
linkedIssues.findAll { it.issueLinkType.name == issueLinkTypeName }.last().destinationObject :
linkedIssues.last().destinationObject
def fieldToCopyId = fieldToCopy.id
switch (fieldToCopyId) {
case fieldManager.&isCustomFieldId:
def customField = ComponentAccessor.customFieldManager.getCustomFieldObject(fieldToCopyId)
def linkedIssueCustomFieldValue = linkedIssue.getCustomFieldValue(customField)
issue.setCustomFieldValue(customField, linkedIssueCustomFieldValue)
break
case IssueFieldConstants.COMPONENTS:
def commonComponents = linkedIssue.components.findAll { it.name in issue.components*.name }
issue.setComponent(commonComponents)
break
case IssueFieldConstants.FIX_FOR_VERSIONS:
def commonFixedVersions = linkedIssue.fixVersions.findAll { it.name in issue.fixVersions*.name }
issue.setFixVersions(commonFixedVersions)
break
case IssueFieldConstants.AFFECTED_VERSIONS:
def commonVersions = linkedIssue.affectedVersions.findAll { it.name in issue.affectedVersions*.name }
issue.setFixVersions(commonVersions)
break
default:
issue[fieldToCopyId] = linkedIssue[fieldToCopyId]
}
But I get unknown methods error. Don't know why...
Someone could help me. thanks
Hi @Dan27,
As mentioned by @informatikus just you need to remove the particular issue type from the issue type scheme of that project.
Let me ask one thing what do you mean by
I want this issue type will create only from workflow,
Hi @Yogesh Mude ,
I have a workflow that create automatically this issue type- So I need it in the scheme.
I don't want that users (in all types) can create this issue type by create screen- So I need to hide it from this screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nope, there is no way to hide the issue type from the create screen unless until you can not remove this from the scheme.
And you can't restrict users on basis of issue type while creating issues.
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.
So you need to provide the access to perticular group/role as a Browse project permission for that specific project so that the users belong to these group/role they can only see the issues but not able to create it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you help me to understand where can I put the java script in this answer:
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.
You say you would like to remove the option to choose a specific issue type?
Why go the hard way scripting out this option instead of just removing the issue type from the project (scheme wise)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @informatikus ,
I want this issue type- but I want this issue type will create only from workflow, and not from the create screen.
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.