Whenever i try to update my custom field , the old value gets deleted and the new value takes its place . But here i need the new value to be appended to the old one .
I am using ScriptRunner for jira .
Hi, Jagadish
You need to use the addLabel () method from LabelManager:
An example can be seen here: https://community.atlassian.com/t5/Jira-questions/How-do-I-add-a-label-as-part-of-the-workflow-transition/qaq-p/245365
addLabel() doesnt work . Its asking to check if 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.
Sorry, Jagadish
I did not notice that the label field is custom. For a custom field of type label, the answer will look like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = issueManager.getIssueObject("MYP-1")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customLabelFieldID = customFieldManager.getCustomFieldObject("customfield_10100").getIdAsLong()
def labelManager = ComponentAccessor.getComponent(LabelManager)
labelManager.addLabel(currentUser, issue.getId(), customLabelFieldID, "123", false)
ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to just add label to existing labels on current issue using post function use this.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.issue.IssueEventBundle;
import com.atlassian.jira.event.type.EventType;
def issueManager = ComponentAccessor.getIssueManager()
def issueFactory = ComponentAccessor.getIssueFactory()
issueManager = ComponentAccessor.getIssueManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def labelManager = ComponentAccessor.getComponent(LabelManager.class)
labelManager.addLabel(currentUser, issue.getId(), "LABEL_NAME", false)
It need to be in scirpt runner post function then issue object exist and you use issue.getId()
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.