Hi,
I would like to auto populate custom field if an issue match jql query results.
I think to use scripted listener but I don't know how to write the script for it.
Can anyone help me please?
Thanks!
You can use escalation service- https://scriptrunner.adaptavist.com/latest/jira/escalation-service.html
I think it's better for you if you want to do it base on JQL result.
You can Build your cron expression here-
https://www.freeformatter.com/cron-expression-generator-quartz.html
Just write there you JQL and add this script: (note that you need to change the "My Custom Field" - to your custom field name and "cf value" to the relevant value)
This code relevant for custom field of type string (Text Field)
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'My Custom Field'}
issueInputParameters.addCustomFieldValue(cf.id, 'cf value')
If your field type is select list use this:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName("Some Select List") // name of CF
def optionsManager = ComponentAccessor.getOptionsManager()
def fieldConfig = customField.getRelevantConfig(issue)
def option = optionsManager.getOptions(fieldConfig).find { it.value == "Yes" } // value of option
issueInputParameters.addCustomFieldValue(customField.id, option.optionId as String)
issueInputParameters.setSkipScreenCheck(true)
Here is an example of an escalation service that run - At 00:00:00am every day and the action is happening as a user how called "admin":
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.