I'm trying to use a Scriptrunner post function to create an issue in a different project.
One of the target customfields is a select list, and I'm trying to working out how to set this field value.
I can see how to do this using getRelevantConfig for the same project, but I don't have this field in my source project, and I can't see how to get this config for a different project when I haven't created the task yet,
The getRelevantConfig method can take an issue object. That's probably what you've seen and used.
But it can also use an issueContext object.
So you so can create a new context based on the project and issue type you plan to create then call the getRelevantConfig with that object to get the options.
Something like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.issue.fields.CustomField
def projectId = 123456L
def issueTypeId = '10010'
def cfId = 10001L
def issueContext = new IssueContextImpl(projectId, issueTypeId)
def customField = ComponentAccessor.customFieldManager.getCustomFieldObject(cfId)
def config = customField.getRelevantConfig(issueContext)
def options = ComponentAccessor.optionsManager.getOptions(config)
That's perfect, many thanks for your clear and quick reply. That's working very nicely for me now. Thanks again
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.