Forums

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

Select list configuration options change on multiple issues at the same time

fguney April 13, 2022

I have a select list where I manage its options by a behavior when another field changed. The options are pulled from external db, so there is nothing static.


def specIdField = getFieldByName("SpecID")
def specNumberField = getFieldByName("Spec Number")
def specVersionField = getFieldByName("Spec Version")
def specTitleField = getFieldByName("Spec Title")
def specVersionOptionsField = getFieldByName("Spec Version Option List")

cfConfig = optionsField.getRelevantConfig(underlyingIssue)
optionsManager.removeCustomFieldConfigOptions(cfConfig)
cfConfig = optionsField.getRelevantConfig(underlyingIssue)

def curSpecId = "0"
def curSpecNumber = ""
def curSpecVersion = ""
def curSpecTitle = ""
if(underlyingIssue != null){
status = underlyingIssue.getStatus().name
activity = underlyingIssue.getCustomFieldValue(cFieldActivity).toString()

curSpecId = customFieldManager.getCustomFieldObjectByName("SpecID").getValue(underlyingIssue)
curSpecNumber = customFieldManager.getCustomFieldObjectByName("Spec Number").getValue(underlyingIssue)
curSpecVersion = customFieldManager.getCustomFieldObjectByName("Spec Version").getValue(underlyingIssue)
curSpecTitle = customFieldManager.getCustomFieldObjectByName("Spec Title").getValue(underlyingIssue)
}

def noneOptionList = [optionsManager.createOption(cfConfig, 1, 0, "None")]

specNumberField.clearError()

if(specNumberField.getValue().toString().length() == 8){
def versions = DatabaseUtil.withSql(dbName) { sql ->
sql.rows("select SpecVer from Spec WHERE SpecRef='"+specNumberField.getValue()+"' ORDER BY SpecVer")["SpecVer"]
}

if(versions != null && versions.size() > 0){

specVersionOptionsField.setHidden(false)

// set option list options
def opts = optionsManager.getOptions(cfConfig)
def newOptions = []
for(String ver in versions){
newOptions.add(optionsManager.createOption(cfConfig, 1, 0, ver))
}
newOptions.add(optionsManager.createOption(cfConfig, 1, 0, "x.x"))

specVersionField.setRequired(false)
specVersionField.setReadOnly(true)

specVersionOptionsField.setRequired(true)

specVersionOptionsField.setFieldOptions(newOptions)

if(curSpecVersion != "" && specNumberField.getValue() == curSpecNumber){
specVersionField.setFormValue(curSpecVersion)
specVersionOptionsField.setFormValue(curSpecVersion)
}

 

When I open an issue and click on edit, then change the value in Spec Number field, the option list will be changed (do not save yet). After that, if I open another issue and change Spec Number, the option list will be changed again regarding to spec number value. Then if I go to the first issue (still on edit screen), selection values in option list doesn't work because configuration of the select list field has changed. Therefore, I cannot save the issue.

 

This happens when different users try to edit different issues at the same time with different values in Spec Number field. I want to create an option list where its config doesn't change (it may change but not affects functionality) but need to set different values on different conditions. 

 

Please help with this issue.

 

(Don't mind if any brackets, parenthesis are wrong in the code block. This is not the full version.)

0 answers

Suggest an answer

Log in or Sign up to answer