I'm trying to create and populate custom fields and options. The example code I found uses the ComponentManager:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManafer = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = customFieldManager.getCustomFieldObjectByName("testgroovy2")
def userCf = customFieldManager.getCustomFieldObjectByName("user picker")
issue.setCustomFieldValue(cf,"Its Works")
issue.setCustomFieldValue(userCf, user)
issueManafer.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
ComponentManager has been deprecated since JIRA 7.11.
I can not find any example code that works in the Script Console.
Can any one out there give me a hand, or point in the right direction.
Hello,
i do this :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManafer = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = customFieldManager.getCustomFieldObjectByName("testgroovy2")
def userCf = customFieldManager.getCustomFieldObjectByName("user picker")
def issue = issueManager.getIssueObject("JIRA-123")
issue.setCustomFieldValue(cf,"Its Works")
issue.setCustomFieldValue(userCf, user)
issueManafer.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
but i have this error :
2020-12-23 18:38:27,266 INFO [runner.ScriptBindingsManager]: cf: [] 2020-12-23 18:38:27,266 INFO [runner.ScriptBindingsManager]: userCf: [] 2020-12-23 18:38:27,266 INFO [runner.ScriptBindingsManager]: issue: JIRA-123 2020-12-23 18:38:27,270 ERROR [common.UserScriptEndpoint]: ************************************************************************************* 2020-12-23 18:38:27,270 ERROR [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setCustomFieldValue() is applicable for argument types: (com.google.common.collect.RegularImmutableList, String) values: [[], Its Works] Possible solutions: setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object), getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField) at Script911.run(Script911.groovy:40)
Please can you help me ?
Thanks
BR
Fayçal
this is a good example, but if you want to use it in console, you need to define issue object before you try to use it:
def issue = issueManager.getIssueObject("JIRA-123")
otherwise it looks like either postfunction or listener piece of code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.