Versions Compared

Key

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

Abstract

This code snippet concatenates two text fields ignoring null values

Logic

Access the text fields and concatenate them

Snippet

Code Block
languagejs
linenumberstrue
org.codehaus.groovy.runtime.NullObject.metaClass.toString = {return ''}
textutils.noNull(<First text field>) + "<Delimiter>" + textutils.noNull(<Second text field>)

Placeholders

Placeholder

Description

Example

<First text field>
Accessing the first text field
linkedIssueissue.get("description").toString()
"<Delimiter>"
Delimiter separating the text fields"\n"
<Second text field>
Accessing the second text field
issue.get("summary")

Examples

The output of this code is a String which you could, for example use in:

A Groovy expression, for example to:

  • Set a text field to the concatenation of two other text fields. Eg: The summary of the issue to the concatenation of two custom field values, say Customer Name and Machine details in:
    • one of the Set Field Value post-functions
    • the Create issue post-function under Set fields of new issue section

      Code Block
      languagejs
      linenumberstrue
      org.codehaus.groovy.runtime.NullObject.metaClass.toString = {return ''}
      textutils.noNull(issue.get("Customer Name")) + "-" + textutils.noNull(issue.get("Machine details"))


A Groovy template, for example to:

  • Include the key and description of the issue in the comment while notifying the customer that when their issue has been resolved in one of the:
    • Comment in one of the Comment issue post-functions
    • Subject/HTML body/Text body of Email issue post-function

      JQL search expression of Link issues current to issue

      Code Block
      languagejs
      linenumberstrue

...

    • Your issue

...

    •  <%=textutils.noNull(issue.getKey())

...

    • %> 

...

    • - 

...

    • <%=textutils.noNull(issue.get("description")) 

...

    • %> 

...

    • has been resolved.

...

  • Compare the text in a conditional execution script to:
    • Run a post-function
    • Run a condition
    • Run a validator
    • Unlink issues

Reference


References

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

...