Hello
I use in script
Option targetOption = ComponentAccessor.getOptionsManager().getOptions(customField.getRelevantConfig(issue)).getOptionById(10000L);
to find and set value for MLCS
Is it possible to take this optionByid from customfield in current issue? Like
def s1 = customFieldManager.getCustomFieldObject(11400)
String s = issue.getCustomFieldValue(s1)
Option targetOption = ComponentAccessor.getOptionsManager().getOptions(customField.getRelevantConfig(issue)).getOptionById("s1"L);
Depending on the field type for your customfield_11400, you may need to need to go one extra level (if it's a single select).
def s1 = customFieldManager.getCustomFieldObject(11400)
String s = issue.getCustomFieldValue(s1).value
Then, rather than "s1"L , you should use the toLong() method
Third, long lines of code are harder to read ... I would suggest you break it down a little
And finally, it may be easier on the users or even you to store the value of the option instead of the id in that other custom field.
So this is how I would write this
def s1 = customFieldManager.getCustomFieldObject(11400)
String s = issue.getCustomFieldValue(s1)
def config = customField.getRelevantConfig(issue)
def options = ComponentAccessor.getOptionsManager().getOptions(config)
Option targetOption = options.getOptionById(s.toLong());
//or
//Option targetOption = options.getOptionForValue(s, null)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.