Spaces:
Sleeping
Sleeping
| # Shared Action | |
| > المصدر: https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461996736/Shared+Action | |
| --- | |
| A post-function that runs a Shared action (a sequence of one or more post-functions) against the current issue (or issues related to the current issue). Shared actions are created through the [Shared Extensions](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461930510 "https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461930510") Administration page. | |
| This post function, together with [Shared extensions](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461930510 "https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461930510"), enables you to reuse the most frequently used configurations quickly without having to create the same configuration multiple times. Any change made to a Shared Extension is instantly applied to all the workflow transitions where that Shared Extension is used. | |
| **To add the 'Shared action' post-function to a transition:** | |
| 1. Click **Edit** for the workflow that has the transition to which the post-function should be added. | |
| 2. In the *Workflow Designer*: | |
| 1. If viewing the workflow as **Text**, click the name of the transition and click the **Post Functions** tab. | |
| 2. If viewing as a **Diagram**, select the transition and click **Post-functions** in the properties panel. | |
| 3. Click **Add post function**. | |
| 4. Select **Shared action** from the list of post-functions and click **Add**. The **Shared Action Post Function** screen (Figure 1, below) will open. | |
| 5. Add the configuration details as specified in the **Configuration details** section, below. | |
| 6. Click **Add** to add the post-function to the transition. | |
| 7. Publish the workflow. | |
| ## Configuration details | |
| Add the following details to configure the post-function to fit your scenario: | |
| ### Shared action | |
| Select the shared action to be run. The list of shared actions displayed here is defined in [Shared extensions](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461930510 "https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461930510"). | |
| ### Target issues | |
| - **Which issues**: Select the issue(s) on which the selected shared action is run. Select one of the following: | |
| - **Current Issue** - Select this option to perform the post-function on the current issue. *This is the default option*. | |
| - **Sub-tasks of the current issue** - Select this option to perform the post-function on the sub-tasks of the current issue. | |
| - **Parent issue of the current sub-task** - Select this option to perform the post-function on the parent of the current issue. | |
| - **Issues that belong to the current Epic** - Select this option to perform the post-function on the issues that belong to the current Epic. | |
| - **Epic of the current issue** - Select this option to perform the post-function on the Epic of the current issue. | |
| - **Child issues of the current issue in the Portfolio hierarchy** - Select this option to perform the post-function on the child issues of the current issue in the Portfolio hierarchy. | |
| - **Parent issue of the current issue in the Portfolio hierarchy** - Select this option to perform the post-function on the parent issues of the current issue in the Portfolio hierarchy. | |
| - **Issues linked to the current issue through any link type** - Select this option to perform the post-function on all issues linked to the current issue *no matter the link type*. | |
| - **Issues linked to the current issue through the following link type** -Select this option to perform the post-function on the issues linked to the current issue through a specific link type. Select the specific link type under **Issue link**, which will appear when this option is chosen. | |
| - **Issues returned by the following Groovy script** - Input a Groovy script that returns either: | |
| - a single [Issue object](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461537734 "https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461537734") | |
| - a Collection of [Issue objects](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461537734 "https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461537734") | |
| - a String representing the key of an issue | |
| - a Collection of Strings each representing an issue key. | |
| For example: | |
| - `"TEST-1"` | |
| - `["TEST-1","TEST-2"]` | |
| - `ComponentAccessor.issueManager.getIssueObject("TEST-1")` | |
| - `[ComponentAccessor.issueManager.getIssueObject("TEST-1"),ComponentAccessor.issueManager.getIssueObject("TEST-2")]` | |
| - `issue.parentObject` | |
| - `issue.getLinkedIssues()` | |
| For more information, refer to [Groovy editor in JMWE](# "#") and [Groovy script tester in JMWE](https://innovalog.atlassian.net/wiki/x/Z6U7C "https://innovalog.atlassian.net/wiki/x/Z6U7C"). | |
| - **Issues returned by the following JQL search** - Input a [JQL search expression](https://www.atlassian.com/software/jira/guides/expand-jira/jql "https://www.atlassian.com/software/jira/guides/expand-jira/jql"), including an optional Groovy Template markup. For example: | |
| - `project = TEST` returns issues of the project with the key TEST | |
| - `project = ${issue.get("project").key} and assignee = ${currentUser.name}` returns issues of the project the current issue belongs to and assigned to the current user. | |
| - To operate on issues of a project with key `TEST` and issue type name same as the value in a text field | |
| `<% if (issue.get("Single line text")) { %> | |
| project = TEST and issuetype = ${issue.get("Single line text")} | |
| <% } else { %> | |
| issuekey=INVALID-1 | |
| <% } %>` | |
| - The `<% if %>` block is necessary to avoid an invalid JQL query when the Single-line text field is empty. In that case, the template returns a valid JQL query that returns no issue (issuekey=INVALID-1). This is in general applicable to JQL operating on select type fields with pre-determined values like Affects Version/s, Checkboxes, etc. | |
| - The maximum number of issues returned by a valid JQL is limited to 1000. | |
| ### Conditional execution | |
| ### Error Handling | |
| Open | |
|  | |
| Figure 1 - Shared Action post-function |