The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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 Champions.
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 Champions.
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

TAGS
AUG Leaders

Atlassian Community Events