3. Asset generic groovy script post function
Adding post function
Add "[AIP] - Asset generic groovy script post function" to the workflows to update an asset object on transition. The groovy script runs only once (not for each asset), all the matching custom fields with asset objects are passed to the post function as context parameter.
See examples, post function specific classes and common classes.
Put the post function in the middle; after issue updates and before GenerateChangeHistoryFunction and Re-index post functions.
Workflow Parameters
Paramater | Description |
---|---|
Asset custom fields (with values) to inject as script parameter | Select the asset custom fields to inject as script parameter. Leave it blank to include all asset custom fields. See context parameters for more information. |
Groovy script | This is the script to be executed |
Context parameters for Groovy Scripts
Please see Sample Groovy Scripts to Create/Update Asset workflow post function for more examples.
Variable Name | Description |
---|---|
assetCustomFieldAndValueList | List of custom fields with values. Its type is List<AssetCustomFieldAndValue>, see https://confluence.snapbytes.com/x/SYGqAQ for class details. And see examples to see how to access Asset values. |
issue | Access current issue. Instance of com.atlassian.jira.issue.Issue. see https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/issue/Issue.html |
originalIssue | Access original issue before the transition. Instance of com.atlassian.jira.issue.Issue. see https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/issue/Issue.html |
ComponentAccessor | Access JIRA components. See https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/component/ComponentAccessor.html |
customFieldManager | Access JIRA Custom Field Manager class. See https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/issue/CustomFieldManager.html |
loggedInUser | ApplicationUser instance for current logged in user. See https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/user/ApplicationUser.html Example: loggedInUser == issue.getAssignee() |
DefaultIssueChangeHolder | Default implementation of a change holder. It is used to update a custom field. |
aipUtils | Helper class for the post function groovy script. See aipUtils for details |
Sample Post Function configuration page
You can add multiple post functions or multiple attributes for one post function.
Try Groovy Scripts
You can immediately execute groovy script so see result. This will let you write and try your groovy scripts faster. Please keep in mind that scripts will be actually executed, if you modify anything please use test objects (issue, asset, etc.)!