Skip to end of banner
Go to start of banner

1. Create Asset workflow post function

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »


Adding post function

Add "[AIP] - Create Asset workflow postfunction" to the workflows to create an asset object on transition. If the conditions pass, post function will create an asset and optionally attaches to the current issue. 



 Put the post function in the middle; after issue creates and before "Update change history for an issue and store the issue in the database." .



Workflow Parameters

ParamaterDescription
Condition 1Groovy script for the post function condition.  Function must return true or condition must be empty to pass. If condition fails post function will be ignored.
Condition 2Asset custom field value must be empty before transition
Link to issueSet newly created asset to asset custom field
Target Asset custom field
Specify the custom field to link asset.
Asset Type
Type of asset to create
Attributes (optional)

Target attribute to set it's value

Context parameters for Groovy Scripts

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

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

Here is an example of all types of attributes.


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

Groovy examples for Asset Attribute Types

Attribute TypeGroovy exampleDescription
CheckboxList
return "ada@@@@@@ist"

Return valid option values wrapped with three @ characters. i.e: @@@ada@@@@@@ist@@@

For a single option value no need to wrap with @ characters.

DatePicker

import java.time.*  
  LocalDateTime t = LocalDateTime.now();  
  return (t as String) 

Result must be in ISO format ("yyyy-MM-dd"), i.e: "2018-12-26".

You do not need to do formatting if you use LocalDateTime class as it returns in ISO format by default.

DateTimePicker
import java.time.*  
  LocalDateTime t = LocalDateTime.now();
  return (t as String) 

Result must be in ISO format ("yyyy-MM-ddTHH:mm"), i.e: "2018-12-26T20:20".

You do not need to do formatting if you use LocalDateTime class as it returns in ISO format by default. If you need to format a date to string, use the format as: "yyyy-MM-dd'T'HH:mm" (Please notice extra single quotes!)

DropdownList
return "ada"
Return a valid option value.
InventoryList
return "3"
Return reference asset ID
InventoryListByForm
return "10"
Return reference asset ID
IP
return  "10.0.0.2"
Any text is possible, there is no format control.
IPv6
return "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
Any text is possible, there is no format control.
ListBox
return "izm"
Return a valid option value.
ListBoxMultiple
return "ada@@@@@@ist"

Return valid option values wrapped with three @ characters. i.e: @@@ada@@@@@@ist@@@

For a single option value no need to wrap with @ characters.

Number - Floatreturn '10.8'
Number - Longreturn '12'
RadioButtonList
return "ist"
Return a valid option value.
Text
return issue.summary
Any text is possible.
TextArea
return issue.description
Any text is possible.
URL
return "http://www.snapbytes.com/"
Any text is possible, there is no format control.
UserPicker
return issue.reporter.username
Any text is possible, there is no control. You may use issue.reporter.username or issue.assignee.username



  • No labels