I found solution here, it tells me use Option object instead of a string value. see https://answers.atlassian.com/questions/10431/how-do-i-update-the-value-of-a-selectcftype-field
But when I tried
Options options = this.getOptions(issueObject, cf);
Option newVal = null;
for(Object obj : options){
Option opt = (Option) obj;
if(opt.getValue().equals(strVal){
newVal = opt;
break;
}
}
issueObject.setCustomFieldValue(envrionmentType, newVal);
or
ModifiedValue modifiedValue = new ModifiedValue(issueObject.getCustomFieldValue(cf), newVal);
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
cf.updateValue(null, issueObject, modifiedValue, changeHolder);
Neither of these two works.
Anybody can help me?