---
title: "Groovy examples"
canonical: "https://support.appfire.com/space/JMWE/462095239/Groovy%20examples"
format: markdown
---
> Macro (aura-html)


#### On creating a Bug set its Affects Version/s to the most recently released version

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the Bug's workflow.
> ℹ️ - Select the `Affects Version/s` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Place the post-function after **Creates issues originally** built-in post-function.

#### Set the Affects Version/s of the issue to Affects Version/s of all its linked issues

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the transition
> ℹ️ - Select the `Affects Version/s` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Select `Ignore empty values` option

#### Assign the issue to the Project lead, if the issue is unassigned on creation

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the issue workflow.
> ℹ️ - Select the `Assignee` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Select `Ignore empty values` option
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### On creating an issue, pick the component of the issue from a cascading field that carries the Main and Sub-components

> ℹ️ - Add the *Set field value to constant or Groovy expression* post-function to the **Create** transition of the issue's workflow.
> ℹ️ - Select the `Component/s` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in it.
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### Set the Component/s of the issue to components whose lead is the current user

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create **transition of the issue workflow.
> ℹ️ - Select the `Components` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

#### On the creation of a sub-task add its summary to the description of its parent

> ℹ️ - Add the *Set field value of linked issues** *post-function to the **Create** transition.
> ℹ️ - Select the `Description` field.
> ℹ️ - Select `is subtask of` in the Issue link type
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### Set the due date to today's date

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the transition.
> ℹ️ - Select the `D``ue date `field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

#### Set the due date to issue created plus five days

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create **transition of the issue workflow.
> ℹ️ - Select the `Due Date `field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

#### On creating a Bug with High priority set its Fix Version/s to the upcoming release

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the Bug's workflow.
> ℹ️ - Select the `Fix Version/s` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Select the Conditional execution and write the following code
> ℹ️ - Place the post-function after **Creates issues originally** built-in post-function.

#### Assign to an unreleased version whose release date is nearest to the issue's due date

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the Bug's workflow.
> ℹ️ - Select the `Fix Version/s` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### Set the Original estimate of the issue to the difference of its creation date and Due date

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the transition.
> ℹ️ - Select the `Original Estimate` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the either of the content in the `Value` section.

#### <span style="color: #707070">Set the priority of the issue to Highest if the issue belongs to the "Customer Portal" component</span>

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the issue workflow.
> ℹ️ - Select the `Priority` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write `Highest` in the `Value` section.
> ℹ️ - Select the `Conditional execution` and write the following content:
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### <span style="color: #707070">On the creation of a Story, change its priority to that of the Epic if the Epic's priority is lower than the current priority of the Story.</span>

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the Story workflow.
> ℹ️ - Select the `Priority` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Select` Ignore empty value` option
> ℹ️ - Place the post-function after the **Creates issues originally** built-in post-function.

#### <span style="color: #707070">Assign a reopened issue to the last person who commented it</span>

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Reopen **transition of the issue workflow.
> ℹ️ - Select the `Assignee` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

#### Assign to the first security level of the project that can be set for an issue created in this project by the current user

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the issue workflow.
> ℹ️ - Select the `Security level` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### On the creation of a Story add the reporter of its Epic to the Watchers

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the issue workflow.
> ℹ️ - Select the Watchers field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Select `Add source value(s) to destination field` option
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### <span style="color: #707070">Epic </span><span style="color: #707070">has a Story </span><span style="color: #707070">and the task has a sub-task. </span><span style="color: #707070">When the sub-task is reopened we create a bug in another project linking it to the sub-task. On creation of the Bug, set the Epic link field value to the same field of the Task</span>

> ℹ️ - Add the *Create/Clone issue** *post-function to the **Reopen **transition of the sub-task workflow.
> ℹ️ - Select the project from `Project`
> ℹ️ - Select the Bug in Issue type
> ℹ️ - Select is caused by in Link to new issue
> ℹ️ - Select the Epic Link field in Set fields of new issue.
> ℹ️ - Select `Set field value from Groovy.`
> ℹ️ - Write the following content in the `Value` section.

####   
<span style="color: #707070">Copy Jira service desk customers in a multi-user picker field to Request Participants ignoring the reporter of the issue</span>

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the transition of the issue workflow.
> ℹ️ - Select the `Request Participants` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

#### <span style="color: #707070">Auto select the installation tasks in a Task checklist after the Installations are done</span>

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the transition that leads to Installations complete status
> ℹ️ - Select the `Tasks checklist` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

#### If a bug is raised with a major outage and is critical select all the customers as impacted

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the issue workflow.
> ℹ️ - Select the `Customers` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Select the Conditional execution check box and write the following code.
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### Update a custom group picker field to the first group the assignee belongs to

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the transition.
> ℹ️ - Select the `Single group picker` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

#### Update a custom multi-group picker field to all the groups the current user belongs to

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the transition.
> ℹ️ - Select the `Multi group picker` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

#### On creating an issue, Copy the component leads of the selected components to a Multi-user picker field

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create** transition of the issue workflow.
> ℹ️ - Select the Multi-user picker field.
> ℹ️ - Select the `Add source value(s) to destination field` option
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.
> ℹ️ - Select `Ignore empty values` option.
> ℹ️ - Place the post-function after the** Creates issue originally** built-in post-function.

#### Save the author of the "Approve" transition in a custom single-user picker field

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the "Approve" transtion.
> ℹ️ - Select the `Single`-user picker type field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.

####   


#### Set a date picker field of a Bug to the Fix Version/s release date

> ℹ️ - Add the *Set field value to constant or Groovy expression** *post-function to the **Create **transition of the issue workflow.
> ℹ️ - Select the `Date picker` field.
> ℹ️ - Select `Groovy expression` in the `Value type`.
> ℹ️ - Write the following content in the `Value` section.