Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-1080

Setting field default on the 'Label' field

    Details

    • Type: New Feature
    • Status: Done
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.3, 5.2.6
    • Fix Version/s: None
    • Component/s: Behaviours
    • Labels:
    • Critical Points:
      1

      Description

      It seems to be impossible to set the default value for the built-in JIRA labels field using behaviours. Calling setFormValue with a list of strings that represent the label or a list of their IDs will return an error in the JavaScript console like:

      Could not add invalid option 10000 to $.appendTo(.appendTo(body)) #labels
      

      Example script; this one came from an end user who was using the behaviour in conjunction with the Create Constrained Issue fragment; the idea is to set the labels of the constrained issue to match that of the one it was created from:

      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.issue.IssueFieldConstants
      import com.onresolve.jira.groovy.user.FieldBehaviours
      import groovy.transform.BaseScript
      
      @BaseScript FieldBehaviours fieldBehaviours
      
      def issueManager = ComponentAccessor.getIssueManager()
      def contextIssue = issueManager.getIssueObject(getContextIssueId())
      def labelObjects = contextIssue.getLabels()
      def labels = labelObjects.collect{it.id}
      getFieldById(IssueFieldConstants.LABELS).setFormValue(labels)
      

      Jamie Echlin suggested to open a support to make this possible. Please see more details in attached.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rholban Roland Holban [X] (Inactive)
              Reporter:
              man2454 Treethawat Man
              Votes:
              5 Vote for this issue
              Watchers:
              17 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: