Hey all,
While I am aware that code in closures should normally be self contained, I'm trying to find a solution to a problem I have. Here is snippet from my code:
String changingValue = body.substring(IndexStart,IndexEnd)
def result = ComponentAccessor.optionsManager.getOptions(customFieldtoUpdate.getRelevantConfig(issueObject))?.find(){
it.toString().equals(changingValue)
}
In a nutshell, "changingValue" is a String that is extracted from an email via a Mail Handler, and the "result" is an Option. As the former variable is different every time, I cannot hardcode the string into the ".equals()" check.
Normally, if I were to update a radio button field, the string alone would work. Here however we are creating an issue from scratch using the issueFactory¹, and no matter how I give the value² for the radio button custom field in this scenario, it only works if it is passed as an "Option", which I'm using the find closure for.
1.
def issueFactory = ComponentAccessor.issueFactory
def issueObject = issueFactory.issue
issueObject.setProjectObject(project)
issueObject.setSummary(subject)
//And so on and so forth...
2.
issueObject.setCustomFieldValue(customFieldtoUpdate, result)
Given that globals don't really exist, any ideas if there is a way I can pass a variable inside? If not, what alternative / workaround could you fetch the radio button option object using only a string?
Thank you for the answers in advance!