Skip to main content
Skip table of contents

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:

Environments added in the field "Environment(s) to book" are added in the Summary

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(", "))
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.