Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create custom type issue using plugin

Egor Erofeev June 4, 2018

Hello,

I'm trying to implement custom type issue using jira plugin.

what steps should be done for custom type issue to appear in "Create" form? (Like "Test" in Zephyr Add-on)

Any suggestions/examples would be highly appreciated.

Thanks!

 

1 answer

1 accepted

1 vote
Answer accepted
Prakhar Srivastav {Appfire}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2018

@Egor Erofeev

You can create any number of issue type from JIRA Admin UI itself.

If you are trying to create issuetype through plugin code then you need to add the new custom issue type in the issuetype scheme for that particular project as well.

Only when the issue type is added to the issue type scheme of a project then only it will be visible in the drop down to Create issue.

 

Regards

Prakhar

Egor Erofeev June 7, 2018

Prakhar, thanks for your answer.

Actually I've succeeded to create an issue of Custom Type using plugin. Java class:

package com.....jira.plugins.jira.customissue;

import com.atlassian.sal.api.ApplicationProperties;
import javax.inject.Inject;
import javax.inject.Named;
import com.atlassian.jira.config.IssueTypeManager;
import com.atlassian.jira.component.ComponentAccessor;


public class NewCustomIssue{
    private ApplicationProperties applicationProperties;

    @Inject
    public void MyPluginComponentImpl(ApplicationProperties applicationProperties){
    IssueTypeManager itm = (IssueTypeManager) ComponentAccessor.getComponentOfType(IssueTypeManager.class);
    itm.createIssueType("Test", "Test", "https://jira.atlassian.com/images/atlassian-jira-logo-large.png");
   

Now my question is how to programmatically add this issue type to issue type of a project.

 

Thanks!

Prakhar Srivastav {Appfire}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2018

Hi @Egor Erofeev

Use the code below . You need to get the issueTypeScheme of your project and then update the scheme with a Collection of issue type ids. 

 

Note : It will replace the current list with whatever you add here , so if you want to retain the old list also then you need to add those ids in the collection.

package com.....jira.plugins.jira.customissue;

import com.atlassian.sal.api.ApplicationProperties;
import javax.inject.Inject;
import javax.inject.Named;
import com.atlassian.jira.config.IssueTypeManager;
import com.atlassian.jira.component.ComponentAccessor;


public class NewCustomIssue{
    private ApplicationProperties applicationProperties;

    @Inject
    public void MyPluginComponentImpl(ApplicationProperties applicationProperties){
   
ProjectManager projectManager = ComponentAccessor.getProjectManager();
Project project = projectManager.getProjectObjByKey("your-project-key");
IssueTypeManager itm = (IssueTypeManager) ComponentAccessor.getComponentOfType(IssueTypeManager.class);
    IssueTypeSchemeManager itsm = ComponentAccessor.getIssueTypeSchemeManager();
FieldConfigScheme issueTypeScheme = itsm.getConfigScheme(project);
IssueType newIssueType = itm.createIssueType("Test", "Test", "https://jira.atlassian.com/images/atlassian-jira-logo-large.png");
Collection<String> options = new ArrayList<String>();
options.add(newIssueType.getId();
itsm.update(issueTypeScheme,options);

 

Regards

Prakhar

Egor Erofeev June 9, 2018

Thanks, Prakhar.

It worked for me.

Suggest an answer

Log in or Sign up to answer