I can't seem to get my script runner mail-handler to fill a custom field of the type "select list".
Is this possible using the messageHandlerContext.createIssue?
I haven't played with the new mail-handler yet ... but have you looked up how to generally set a select custom field using scriptrunner? There are loads of examples here on the community.
My guess, after a quick read of the documentation, is that the messageHandlerContext.createIssue requires an issueObject created with issueFactory
From there you will need something like this
/* what comes before to get issueObject*/
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
//get the custom field and all the options relevant for the current issue
def mySelectCf = customFieldManager.getCustomFieldObject('customfield_xxxxxx')
//alternate method for getting custom field, not safe if same name is used more than once
//def mySelectCf = customFieldManager.getCustomFieldObjectByName('Select List Friendly Name')
def mySelectContextConfig = mySelectCf.getRelevantConfig(issueObject)
def selectOptions = optionsManager.getOptions(mySelectContextConfig)
//find the option you want to apply
def myOption = selectOptions.find{it.value == 'MySelectValue'}
if(myOption){
issueObject.setCustomFieldValue(mySelectCf, myOption)
}
messageHandlerContext.createIssue(user, issueObject)
Hi Peter-Dave,
Now this makes me feel silly. Had to get the relevant config after defining the issueobject. Weekend was past due. It works just fine.
My apologies and gratitude,
Bob
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.