The Linked Issues Field
You can use Behaviours to work with the Linked Issues field, similar to how you work with other fields. However, as it's a composite field consisting of two fields you must set the value differently from other fields.
Reading the Linked Issues field value
To get the value of the Linked Issues field, you can do the following:
// Return a String, for example, blocks or is caused by
getFieldById("issuelinks-linktype")
// Return an array, even an empty one
getFieldById("issuelinks-issues")Setting the Linked Issues field value
To set the value of the Linked Issues field you need to set the two values separately, for example:
getFieldById("issuelinks-linktype").setFormValue("is blocked by")
getFieldById("issuelinks-issues").setFormValue(["SSPA-1", "SSPA-2"])Other operations
You can perform operations on the entire Linked Issues field or its individual components, for example:
// Make the entire Linked Issues field read-only
getFieldById('issuelinks').setReadOnly(true)
// Or operate on individual components
getFieldById('issuelinks-linktype').setReadOnly(true)
getFieldById('issuelinks-issues').setReadOnly(true)
// You can also make fields required, hidden, etc.
getFieldById('issuelinks').setRequired(true)
getFieldById('issuelinks-linktype').setHidden(false)Example: Limit the available issue link types for issues in a project
In the following example we want to limit the available issue link types for issues in a specific project so that we can easily create and maintain JQL filters to find issues with certain link types. We can use the following script to restrict the link type options to only those we have approved in the Create or Update form of an issue.
You can now test your behaviour works by creating or updating an issue and seeing the limited linked issue options.