I tried using both scripts on https://answers.atlassian.com/questions/307827 but neither were successful. When adding the script, the error says "cannot find matching method...". Has anyone been successful with this? Thank you!
"cannot find matching method..."
That's all about error or is there something else? Seems to be something more.
Try to debug both scripts in a script runner - works for me as well.
The API may have changed since that answer. As Aleks said, the useful part of the error you get is in the "...".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.label.LabelManager def user = ComponentAccessor.jiraAuthenticationContext.getUser() LabelManager labelManager = ComponentAccessor.getComponent(LabelManager) def labels = labelManager.getLabels(issue.id).collect{it.getLabel()} labels += 'new_label' labelManager.setLabels(user,issue.id,labels.toSet(),false,false)
The error I get is:
"Static Type Checking -Cannot find matching method: com.atlassian.jira.issue.label.LabelManager#setlabels(com.atlassian.jira.user.Ap
java.lang.Long, java.util.Set , boolean, boolean). Please check if the declared type is right and the method exists"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The exact script I'm getting this error on is below (the code block above didn't work for some reason):
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def user = ComponentAccessor.jiraAuthenticationContext.getUser()
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
def labels = labelManager.getLabels(issue.id).collect{it.getLabel()}
labels += 'new_label'
labelManager.setLabels(user,issue.id,labels.toSet(),false,false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm... Which JIRA version do you use? Maybe it is old enough and do not have this method
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, there is difference. In JIRA 7 method signature is
setLabels(ApplicationUser remoteUser, Long issueId, Set<String> labels, boolean sendNotification, boolean causeChangeNotification)
but in 6.4.6
setLabels(com.atlassian.crowd.embedded.api.User remoteUser, Long issueId, Set<String> labels, boolean sendNotification, boolean causeChangeNotification)
Try to replace last string this way:
labelManager.setLabels(user.getDirectoryUser() ,issue.id,labels.toSet(),false,false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
This code creates a "labels" , not a specific custom field with label type..
How can I set value in a custom field (with label type)
Thanks,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nicole The code snippet by you above does not add new labels in the LABEL table, instead it updates the existing record in LABEL table.
Any update from your side for same?
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.