Example: Compose dynamic text by inserting field values in a text template
You can compose dynamic texts by inserting field codes among fixed parts of text. These field codes will be replaced with field values at transition execution time. Use post-function Copy parsed text to a field to set a field (custom or virtual) with a text template where inserted field codes (using format %{xxxxx}) will be replaced with field values at transition execution time. You will often use Copy parsed text to a field in combination with post-functions Write field on linked issues or sub-tasks, Update issue fields and Set a field as a function of other fields.
In those cases you select an ephemeral field ("Ephemeral string 1", "Ephemeral string 2", ... "Ephemeral string 5") as Target field in post-function Copy parsed text to a field, in order to hold temporarily the result text once parsed. Then you can use post-functions Write field on linked issues or sub-tasks or Update issue fields to write it into other issues' fields (e.g., linked issues, transitively linked issues, sub-tasks, sibling sub-tasks, or any issue returned by a JQL query). Also post-function Set a field as a function of other fields can be used in order to conditionally write the parsed text according to simple or complex setting rules that depend on the value of other fields' values.
When Copy parsed text to a field post-function is executed, field codes (using format %{xxxxx}) inserted in the text template are replaced with current fields' values. We want a dynamically compose a text that will be added as a comment at the moment of issue closing.
Using post-function Copy parsed text to a field we store into auxiliary field "Ephemeral number 1" the result of having parsed the text template we use to compose the comment.
Text to be parsed used in this example is: "The issue has been closed on " + %{00057} + " by " + %{00021} + ", and has remained " + (({00057} - {00009}) / {DAY}) + " days open."
Note that:
- %{00057} is code for string value of "Current date and time"
- {00057} is code for numeric value of "Current date and time"
- %{00021} is field code of "Current user's full name"
- {00009} is code for numeric value of "Date and time of creation"
Using post-function Add a comment we insert a comment with text stored in field "Ephemeral string 1", setting desired visibility for the comment, and the user who will be appear as comment's author.
Once configured the transition looks like this:
More about this example
- Since version 2.1.19 you have available a virtual field called New comment. You can use it to insert a new comment using post-function Copy parsed text to a field simply by selecting it as target field.
- Since version 2.2.1 post-function Add a comment contains a text box where the text can be directly composed (using basic parsing mode). Since this version of the plugin, the 2 steps approach explained in this example only makes sense when you need to compose a text using advanced parsing mode.
Other examples of that functions
- Compose dynamic text by inserting field values in a text template
- Creating a Jira Service Desk internal comment
- Creating a Jira Service Desk internal comment on linked issues
- Add all assignees of certain sub-task types to a "Multi-User Picker" custom field
- Add and remove a single or a set of items from multi valued fields
- Add current user to comment
- Add or remove request participants
- Add watchers from a part of the issue summary: "Summary_text - watcher1, watcher2, watcher3, ..."
- Assign issue based on the value of a Cascading Select custom field
- Assign issue to last user who executed a certain transition in the workflow
- Automatically close resolved sub-tasks when parent issue is closed
- Automatically reopen parent issue when one of its sub-tasks is reopened
- Calculate the time elapsed between 2 transition executions
- Close parent issue when all sub-tasks are closed
- Combine the values of several Multi-User picker fields
- Compose a parsed text including the "full name" or a user selected in a User Picker custom field
- Compose dynamic text by inserting field values in a text template
- Copy issue labels to a custom field
- Copy the value of a user property into a user picker
- Create a comment in sub-tasks when parent transitions
- Execute transition in epic
- Getting the number of selected values in a custom field of type Multi Select
- Limit the number of hours a user can log per day
- Make a sub-task's status match parent issue's current status on creation
- Make parent issue progress through its workflow
- Moving story to "In Progress" when one of its sub-tasks is moved to "In Progress"
- Moving story to "Ready for QA" once all its sub-tasks are in "Ready for QA" status
- Parse Email adresses to watchers list
- Parsing text from last comment and appending it to issue's summary
- Remove versions selected in a version picker custom field
- Replace certain issue link types with different ones
- Restrict parent issue from closing if it has sub-tasks that were created during a given parent issue status
- Set a Select or Multi-Select field using regular expression to express the values to be assigned
- Set assignee depending on issue type
- Set field depending on time passed since issue creation
- Set priority for issues that have been in a certain status for longer than 24 hours
- Set security level based on groups and project roles the reporter or creator are in
- Transition linked issues in currently active sprint
- Transition only a sub-task among several ones
- Transition parent issue only when certain issue sub-task types are done
- Update Cascading Select custom field with a value of the field in parent issue
- Update checkboxes custom field if a file has been attached during a transition
- Validation on issue attachments
- Validation on MIME types of issue attachments
- Writing a comment to blocked issues when blocking issues are resolved