I have a Behaviour script that sets the selected values for one custom field (Required Reviewers) based on the selection from another single select list (Mission Phase). The field that the behaviour is set on (Mission Phase) is marked as required.
The scripts works perfectly fine normally, unless I try to create an issue without selecting a value in the required field (defaults to None). When I do this, I get the normal error saying Mission Phase is Required, but selecting values in this field no longer update the selected values in the Required Reviewers field.
When I put log messages in the script, everything is being called correctly, it's getting the correct values from the fields, etc. And I briefly see a little wheel at the bottom of the Create screen, but nothing else. I get no errors in the log.
Is there something I need to add to the script to force this? Or is there a reason why when a Create screen gets these required errors a behaviour would stop updating other fields correctly?
Hi Jason.
Can I take a look at the script?
If you are setting the value of a select list I assume you are using the options manager to get the option by passing it the fieldConfig. My suspicion is that it may be something to do with this.
Thanks
Johnson Howard (Adaptavist)
Sure, here it is
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.customfields.option.Option
class MissionPhaseDefault extends com.onresolve.jira.groovy.user.FieldBehaviours
{
def commList = ['SI Lead', 'WF Lead', 'MSE', 'MOM', 'OC', 'bMOC']
def normList = ['OC', 'MOM']
def tsrList = ['TLC']
def run()
{
def missionValue = getFieldByName("Mission Phase").getValue()
def list = null
if(issueContext.issueType.name = "Timeline Scheduling Request")
{
list = tsrList
}
else if(missionValue.equals("Normal Ops"))
{
list = commList
}
else if(missionValue.equals("Normal Ops"))
{
list = norList
}
def reqField = getFieldByName("Required Reviewers")
def reqCustom = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(reqField.getFieldId())
def config = reqCustom.getRelevantConfig(getIssueContext())
def options = ComponentAccessor.getOptionsManager().getOptions(config)
def optionsToSelect = options.findAll{it.value in list}
reqField.setFormValue(optionsToSelect*.optionId)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And is the field set as required in the field configuration or by another behaviour?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jason,
It turns out that this was actually a previously known issue and has actually been fixed in the latest version. If you update your ScriptRunner version then this issue should not persist.
Let me know if you still have the issue after the upgrade.
Thanks
Johnson Howard (Adaptavist)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It was marked as required through the normal field configuration, not a behaviour.
Awesome, I'll download the latest and see how it behaves and will let you know. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great, would you mind marking this answer as Accepted please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can this answer be marked as accepted please Jason?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.