Set Issue Attributes

You can see some issue attributes as part of a post-function, for instance components, versions, custom and system fields.

The following example covers these areas.

You can only use this method to update issue attributes if your script post-function comes before the standard function Update change history for an issue and store the issue in the database. If you need your function to run after that, you have to use a more complex method.

import java.time.LocalDate

issue.set {
    setFixVersions('1.1')
    setComponents('MyComponent')

    // a text field
    setCustomFieldValue('TextFieldA', "Some text value")

    // a date time field - add 7 days to current datetime
    setCustomFieldValue('Date Picker') {
        set(get().plusDays(7))
    }

    // checkboxes, radio buttons, single and multi selects
    setCustomFieldValue('Checkboxes', 'Yes')

    // a user custom field
    setCustomFieldValue('UserPicker', 'admin')

    // system fields
    setDescription("A generated description")

    // set due date to tomorrow
    setDueDate {
        set(LocalDate.now().plusDays(1))
    }
}

Line 24: These are custom field names, not IDs. Alternative you can use customFieldManager.getCustomFieldObject("customfield_12345"), which will allow you to change the field name, however, you lose portability between Jira instances.

Setting Checkbox Fields

Action required

Unauthenticated access to this resource is not allowed. Please login to Confluence first.

Line 10: The custom field value is a Collection of Option objects

Setting Radio Button Fields

Identical to the above example, except the custom field contains only a single Option, so do not create a List, example:

issue.setCustomFieldValue(cf, option)
On this page