Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script Runner - Set Field (Select List) to value

Rob B
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 16, 2022

Im using Script Runner post function to create a linked issue, but i also want to use the "Additional issue actions" to set a field (select list) value on linked case.

I have this but it stops the linked case from being created all together.....

 

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def formField = getFieldByName("Field Name 1")

def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find {
it.value == "Value 1"
}
formField.setFormValue(optionToSelect.optionId)

 

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
March 18, 2022

Hi @Rob B

From your description:-

Im using Script Runner post function to create a linked issue, but i also want to use the "Additional issue actions" to set a field (select list) value on linked case.

I have some doubts to clarify with you, i.e. 

1. Do you want the Additional issue actions to be updated using Behaviour?

2. If it is for the Behaviour, could you please share a print screen of your Behaviour configuration?

3. And is it configured for either a Server-Side Behaviour or Initiliser?

If it is configured for a Server-Side Behaviour, this code will not work.

For the Server-Side Behaviour, you need to declare the field the Behaviour is configured for like this:-

def field = getFieldById(fieldChanged)

For more information on the Behaviours, you can visit the Adaptavist Documentation.

I am looking forward to your feedback.

Thank you and Kind Regards,

Ram

Suggest an answer

Log in or Sign up to answer