Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Abstract

This code snippet unchecks a specific value of a standard or custom multi-valued type field (typically a multi-select field). The multi-valued fields can either be a collection of objects or a set of values. While unchecking all is easy (set the field with a blank value), unchecking only a particular option/value requires code. 

...

PlaceholderDescriptionExample
<Labels field>Name of the Labels fieldLabels
<Label to remove>Label to be removedMerged

Examples

The output of the code is an array of objects which you could use in a Groovy expression to remove a particular option from the selected options of a field in one of the Set Field Value post-functions and the Create issue post-function under Set fields of new issue section.

  • Remove the reporter from the JIRA service desk customers

    Code Block
    def newValues = issue.get("JIRA Service Desk customers").findAll{
      it.getName() != issue.get("reporter").getName()
    }
    return newValues


  • Clear the option "To Print" after the print has been generated

    Code Block
    def newValues = issue.get("Documents processing").findAll{
      it.getValue() != "To Print"
    }
    return newValues


  • Remove the label "Merged" when QA re-opens a ticket that has been merged into master and handed over to QA.

    Code Block
    def newValues = issue.get("Labels").findAll{
      it.getLabel() != "Merged"
    }
    return newValues


...

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "jmwe-groovy" and type = "page" and space = "KBJMWE"
labelsjmwe-nunjucks jmwe-cloud

...