Add a value in Components part of a project Edited

Hi guys, 

I am trying to develop a groovy script (post function) which add a value in Components part of a Project.

I  have the following error :

No signature of method: com.atlassian.jira.ComponentManager.getProjectComponentManager() is applicable for argument types: () values: []

 

create(String name, String description, String lead, long assigneeType, Long projectId)

 I think the problem come from the fourth parameter, I have put 0 because I don't know how to get the right value.

 capture script.PNG

Here is my code : 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.bc.project.component.ProjectComponent
import  com.atlassian.jira.bc.project.component.ProjectComponentManager

OptionsManager optionsManager = ComponentAccessor.getOptionsManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
ComponentManager componentManager = ComponentManager.getInstance()

//MutableIssue issue = issue
def issue = ComponentAccessor.getIssueManager().getIssueObject("CTY-213")


def userProjectId = 13900
def component = componentManager.getProjectComponentManager().create("test toto","description","leadtoto",0,userProjectId)

2 answers

1 accepted

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.bc.project.component.ProjectComponent
import  com.atlassian.jira.bc.project.component.ProjectComponentManager

OptionsManager optionsManager = ComponentAccessor.getOptionsManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
ComponentManager componentManager = ComponentManager.getInstance()
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
MutableIssue issue = issue
//def issue = ComponentAccessor.getIssueManager().getIssueObject("CTY-213")

CustomField newApplication = customFieldManager.getCustomFieldObject((long)20210) //PP et P
def cfValue = issue.getCustomFieldValue(newApplication).toString()
CustomField mainOwner = customFieldManager.getCustomFieldObject((long)20206) //PP et P
def cfValueMainOwner = issue.getCustomFieldValue(mainOwner).toString()
String []name=cfValueMainOwner.split("\\(")

def userProjectId = 13900
def component = projectComponentManager.create(cfValue,"",name[0],1,userProjectId)
return component

Shame on me, the function getProjectComponentManager seems not existing anymore. I have to find another function to do what I want. Any ideas ?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

63 views 0 11
Read article

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