Scriptrunner - getRelevantConfig For Different Project

Dalectric
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 6, 2023

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,

1 answer

1 accepted

1 vote
Answer accepted
Peter-Dave Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2023

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)
Dalectric
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2023

That's perfect, many thanks for your clear and quick reply. That's working very nicely for me now. Thanks again

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events