I used the following code to hide my custom issue from the create screen. I am doing this because I do not want all users to create this issue type using the create screen . The reason being is that I am creating this issue using a custom listener that creates this custom issue when ever a sprint is getting created and the issue type goes under the sprint.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.option.OptionSetManager
import com.atlassian.jira.issue.fields.config.FieldConfigScheme
import com.atlassian.jira.issue.fields.option.OptionSet
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.project.Project
def targetissuetypeID = "10600" //custom issue type 1
def projectKey = "ABC"
//get needed components
def itsm = ComponentAccessor.issueTypeSchemeManager
def opsm = ComponentAccessor.getComponent(OptionSetManager)
def pm = ComponentAccessor.projectManager
//set vars with required objects from user input
def proj = pm.getProjectByCurrentKey(projectKey)
def issueTypes = itsm.getIssueTypesForProject(proj)
//get fieldconfig scheme for target project. you should maybe check if scheme is not global so that other projects are not affected
FieldConfigScheme scheme = itsm.getConfigScheme(proj)
//issue types that can be seen in 'create issue' screen are stored as options
OptionSet options = opsm.getOptionsForConfig(scheme.getOneAndOnlyConfig())
def newoptionsArray = []
newoptionsArray = options.getOptionIds()
//remove target issue type
newoptionsArray.remove(targetissuetypeID)
itsm.update(scheme, newoptionsArray)
using the above code the custom issue type 1 is being removed from the create issue . I am getting and invalid issue type error when I click on the edit issue button for the issue type (custom issue type 1) that I created using the automated process using a a custom script runner .
Here is my custom listener which creates the custom issue type 1 when ever the sprint is created. This piece of code is also working. But when I click on the edit button after the custom issue type 1 is created , I am getting invalid issue type error. It looks like that the first piece of code is having impact on this .
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager
def issueFactory = ComponentAccessor.getIssueFactory()
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def newIssue = issueFactory.getIssue()
def project = ComponentAccessor.projectManager.getProjectByCurrentKey("ABC")
def IssueType = ComponentAccessor.constantsManager.getAllIssueTypeObjects().find { it.getName() == "custom issue type 1" }
def sprintCF = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Sprint")
// Get sprint field from the issue fields as a Map
newIssue.setSummary(" custom issue type 1 created for ${sprintCF}")
newIssue.setProjectObject(project)
newIssue.setIssueType(IssueType)
newIssue.setCustomFieldValue(sprintCF, [event.sprint]) //add the issue to the sprint that just started and triggered the event
//... any other fields
Map<String,Object> newIssueParams = ["issue" : newIssue] as Map<String,Object>
ComponentAccessor.issueManager.createIssueObject(loggedInUser, newIssueParams)
Could you please help me with this issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.