Set project Field Configuration Scheme programmatically

Hi, We are trying to set some project schemes programmatically for an inside development. We are able to set some schemes like: notification scheme, issue security scheme, permission scheme, issue type screen scheme, etc. using WorkflowSchemeManager, PermissionSchemeManager, etc etc etc. But we don't know how to set the Field Configuration Scheme and the Issue Type scheme Any ideas on how can we set those 2 schemes to projects??? Regards

4 answers

try with this

FieldConfigurationScheme srcProjectFieldLayout = fieldLayoutManager.getFieldConfigurationScheme(srcProjectGV)
        if (srcProjectFieldLayout) {
            fieldLayoutManager.addSchemeAssociation(newprojectGV, srcProjectFieldLayout.getId())
        }

for your reference

https://bitbucket.org/jamieechlin/scriptrunner-public/src/f37f6c2d74aa/src/main/resources/com/onresolve/jira/groovy/canned/admin/CopyProject.groovy

@Iryna, if some thing helped you don't forget to voteup/accept as a answer,

it will help other users to choose right answer

this doesn't copy IssueTypeScheme, but I found a solution in your reference.

Thanks =)

Hi all,

for the issue type scheme (based on AssociateIssueTypeSchemes):

FieldConfigScheme newIssueTypeScheme = fieldConfigSchemeManager.getFieldConfigScheme(issueTypeSchemeId);

        JiraContextTreeManager treeManager = ComponentManager
                .getComponentInstanceOfType(JiraContextTreeManager.class);

        // Set the contexts
        List<JiraContextNode> contexts = CustomFieldUtils.buildJiraIssueContexts(false,
                null,
                new Long[]{project.getId()},
                treeManager);

        ConfigurableField configurableField = newIssueTypeScheme.getField();
        fieldConfigSchemeManager.updateFieldConfigScheme(newIssueTypeScheme, contexts, configurableField);

        fieldManager.refresh();

and for the field layout configuration scheme:

FieldLayoutScheme fieldLayoutScheme = fieldLayoutManager.getMutableFieldLayoutScheme(fieldLayoutSchemeId);
      fieldLayoutManager.addSchemeAssociation(project, fieldLayoutScheme.getId());

Thanks, you saved me.

But can you tell how you retrieve issueTypeSchemeId in your example ?

i ahve given link check there you will get entire code

IssueTypeScheme has a manager

e.g.

issueTypeSchemeManager.create("name of scheme", "description", issueTypdIds);

The issueTypeIds is a List of Strings whose id's are the IssueTypes to go in that scheme

I'll checkout FieldConfigurationScheme as was looking at that recently myself

Hi. Have you found any solution for setting Issue Type Scheme?

I actually tried to set it with IssueTypeSchemeManager but couldn't do it till now.

But Field Configuration you can set with this (here i was copying scheme from one project to another, but i think this will be the same with created scheme):

com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager flmanager = ComponentManager.getInstance().getFieldLayoutManager();

org.ofbiz.core.entity.GenericValue projectFrom = pmanager.getProjectByKey(keyFrom);

org.ofbiz.core.entity.GenericValue projectTo = pmanager.getProjectByKey(keyTo);

com.atlassian.jira.issue.fields.layout.field.FieldConfigurationScheme fieldConfigurationScheme = flmanager	.getFieldConfigurationScheme(projectFrom);

Long fieldLayoutSchemeId = fieldConfigurationScheme.getId();

flmanager.addSchemeAssociation(projectTo, fieldLayoutSchemeId);

Hi. i found a solution here https://bitbucket.org/topmanage/tm-project-templates/overview

hope this can help you

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

463 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you