Forums

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

Set the flagged using Behaviours

Shawn Danisa August 23, 2018

I would like to automatically set the flagged(impediment) field using JIRA ScriptRunner Behaviours.

 

Below is my script:

 

def flagged = getFieldById("customfield_10100")

flagged.setFormValue(["Impediment"])

 

This does not seem to work and I am not getting errors either.

 

Please assist

 

1 answer

0 votes
Mark Markov
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.
August 23, 2018

Hello @Shawn Danisa 

What type is flagged field? And where you put your script, initialiser or mapped to a field?

Shawn Danisa August 23, 2018

Hi @Mark Markov

It's a checkbox

Mark Markov
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.
August 23, 2018

If you want to set Form value for selectlist or check box, you must provide option id.

Like this

import com.atlassian.jira.component.ComponentAccessor

def flagged = getFieldById("customfield_10100")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(flagged.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find { it.value == "Impediment" }
flagged.setFormValue(optionToSelect.optionId)

See scriptrunner documentation for more information

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events