Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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  examplespost 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

ParamaterDescription
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 scriptThis is the script to be executed

Context parameters for Groovy Scripts

Please see Sample Groovy Scripts for Update Asset workflow post function for more examples.

Variable NameDescription
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

ComponentAccessorAccess 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.

aipUtilsHelper 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.)!



Table of Contents