Behaviours - Fields update
In this example, we update the issue Summary with the list of Environments selected in an Environment Custom Field. As the custom field returns a list of Environment IDs, we use the Golive CustomFieldType to get the Environment names:
![](../../../__attachments/425361525/spaces%252F-MWcvo1Q5iQLYT9dKP7d-855039963%252Fuploads%252Fgit-blob-fae4a6347deee9bc907e6299d573634e84c26ed3%252Fimage.png%3Falt=media?inst-v=3ffa38e5-3b9f-4ccd-983f-55750894a4d3)
Environments added in the field "Environment(s) to book" are added in the Summary
![](../../../__attachments/425361525/spaces%252F-MWcvo1Q5iQLYT9dKP7d-855039963%252Fuploads%252Fgit-blob-5e85b8d7fa7f46161572a6d874be479781a3331c%252Fimage.png%3Falt=media?inst-v=3ffa38e5-3b9f-4ccd-983f-55750894a4d3)
ScriptRunner Behaviour Field setup
GROOVY
package com.apwide.golive.example
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.apwide.env.api.GoliveAccessor
@WithPlugin("com.holydev.env.plugin.jira-holydev-env-plugin")
@PluginModule
GoliveAccessor goliveAccessor
// Get the list of Environments' IDs from the Environment CF
List<String> envIds = getFieldById("customfield_10508")?.getValue() ?: []
// Get the list of Environments' names from the list of IDs
def envNames = envIds.collect { envId -> goliveAccessor.golive().environments.getById(envId).name }
// Update the Summary field with the list of Environments
getFieldByName("Summary").setFormValue("Booking " + envNames.join(", "))