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 Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,065 views 6 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot