Clone wiki

JIRA Workflow Toolbox / post-functions / Add A Comment

Add a comment

This post-function creates a comment in current issue using the content of a field, setting the visibility by project role, by user group or Jira Service Desk's internal / public visibility modes. Comment author can be selected among user fields, or leave as anonymous comment using an empty field.

Text of the comment can be introduced directly in the post-function, or be composed previously using "Copy a parsed text to a field" post-function, and stored into an ephemeral string field.

Comments can also be created in related issues using "Write field on linked issues or subtasks" or "Write field on issues returned by JQL Query or Issue List" for writing into virtual fields "New comment" and "New comment (sends email notifications)".

Example: Create an Automatic Issue Closing Comment

Using JIRA Workflow Toolbox 2.2.1 or higher versions:

We use "Add a comment" post-function for composing the text of the message and creating the comment with the desired visibility restrictions:

./post-functions/add-comment/ex1-conf-0-0.png
./post-functions/add-comment/ex1-conf-0-1.png

Note that:

  • %{00021} is field code for "Current user's full name".
  • %{00057} is field code for "Current day and time".
  • %{00028} if field code for "Resolution".


Using JIRA Workflow Toolbox 2.2 or lower versions:

We will use 2 post-function to implement this usage example:

1) We use "Copy a parsed text to a field" post-function for composing the text of the comment, and storing it into "Ephemeral string 1":

./post-functions/add-comment/ex1-conf-1.png

Note that:

  • %{00021} is field code for "Current user's full name".
  • %{00057} is field code for "Current day and time".
  • %{00028} if field code for "Resolution".

2) We us "Add a comment" post-function for creating a comment using the text stored in field "Ephemeral string 1":

./post-functions/add-comment/ex1-conf-2.png

Once configured, the transition looks like this:

./post-functions/add-comment/ex1-final-conf.png

JIRA Workflow Toolbox provides a series of virtual fields related with comments that can be used with all the features of the plugin:

Writable virtual fields

Field NameEffect of WritingAllowed String ValuesAllowed Numeric ValuesExamples
Last commentUpdates the last comment added to the issue if it existsunlimited text string

Optionally parameter visibility can be added for setting comment visibility. To do it add ": {visibility:visibility_value}" at the end of the text. This parameter admits the same values as "Last comment's visibility restriction". (See example)
Since version 2.2
numbers are cast to stringWARNING: When writing into this field, please add your writer post-function AFTER "Add a comment to an issue if one is entered during a transition." post-function, since otherwise updated comment will be the one before last, instead of the last one. Example
Last comment's visibility restriction
Formerly called "Last comment's visibility"
Updates the visibility of the last comment in the issue if it exists. Can be used to set the visibility of a comment introduced with virtual field New commentname of a Project Role or name of a Group.

In Jira Service Desk it also admits values public and internal, or alternatively jsd_public and jsd_internal to avoid name collision with existing project roles and user groups.
Since version 2.2
n/aDevelopers: for setting visibility to project role or group with name Developers.

jsd_internal: for setting JSD internal visibility.

jira-developers: for setting visibility to "jira-developers" user group.
New commentInserts a new comment into the issueunlimited text string

Optionally parameter visibility can be added for setting comment visibility. To do it add ": {visibility:visibility_value}" at the end of the text. This parameter admits the same values as "Last comment's visibility restriction". (See example)
Since version 2.2
numbers are cast to string* This is a comment only visible to developers group.: {visibility=jira-developers}
* This is a comment only visible to Admin project role.: {visibility=Administrators}
* This is a comment only visible to Jira Service Desk agents and collaborators.: {visibility=jsd_internal}
* This is a comment also visible to Jira Service Desk customers.: {visibility=jsd_public}

Virtual field "New comment" and "New comment (sends email notifications)" can be used in combination with "Write field on linked issues or subtasks" or "Write field on issues returned by JQL Query or Issue List" for adding comments to other issues (linked issues, subtask, JQL selected issues, or issues returned by an issue list expression.

Optional Parameter {visibility=visibility_value}:

Since version 2.2 parameter visibility can be added at the end of comment's text in order to set visibility restrictions. To do it simply add ": {visibility=visibility_value}" at the end of the comment's text. Let's see some examples:

  • This is a comment only visible to developers group.: {visibility=jira-developers}
  • This is a comment only visible to Admin project role.: {visibility=Administrators}
  • This is a comment only visible to Jira Service Desk agents and collaborators.: {visibility=jsd_internal}
  • This is a comment also visible to Jira Service Desk customers.: {visibility=jsd_public}

Values returned when reading virtual fields

Field nameTypeValue returned when cast to stringExamples
Last commentText stringLast comment entered in the issue.-
Last comment's visibility restrictionText stringName of a group or project role the visibility of the last comment entered in the issue is restricted to. If no restriction is applied to the comment, this field is returns an empty string. For Service Desk's special Internal visibility restriction, string Internal is returned. This field can be used to check visibility restriction of field entered in transition when it exists.-
Last commenter
(since version 2.1.33)
UserName of the user who entered the last comment in the issue.galileo.galilei
Transition's commentText stringComment entered in transition screen. This field can be used to make comment mandatory in transition screen, or to validate the content of comment entered in a transition.-

Usage Examples

Updated