Looking for custom code for a post function that sets a value of an InTENSO [Dynamic Forms] - Dynamic Select field on transition with scriptrunner.
Couldn't find anything yet. The code below didn't seem to work from scriptrunner's website.
import com.atlassian.jira.component.ComponentAccessor
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Favourite Fruit")
def cfConfig = selectCf.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {
it.toString() == 'Lemons'
}
issue.setCustomFieldValue(cfSelect, value)
For anyone who needs this in the future...this worked:
import com.atlassian.jira.component.ComponentAccessor
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Favourite Fruit")
def cfConfig = cfSelect.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {
it.toString() == 'Lemons'
}
issue.setCustomFieldValue(cfSelect, value)
I would recommend that you use the Script Console to see what data you get from your various statements. For instance, try returning value:
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find { it.toString() == 'Lemons'}
//add below statement right after the above statement
return value
What do you get?
You will have to define issue first though
def issue = ComponentAccessor.getIssueManager().getIssueObject("ISSUEKEY HERE")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
received this error:
groovy.lang.MissingPropertyException: No such property: ComponentAccessor for class: Script88 at Script88.run(Script88.groovy:1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need the rest of your script too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.