Hi,
I have a custom field which needs to have issue key in formatted form(e.g if issue key is
TT-41, the value in custom field should be TT41). I have scriptrunner and i have written some code to retrieve issue key but is showing some error.
Can someone help with my code to get issue key copied to custom field in formatted value?
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.*
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.event.issue.DelegatingJiraIssueEvent;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.issue.IssueEventBundle;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventType;
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.sql.Sql
import java.sql.Driver
import com.atlassian.jira.issue.MutableIssue;
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10503");// here replace the ID with ID of your custom field.
def issueManager = ComponentAccessor.getIssueManager()
//Issue issue = issue
def issue = issueManager.getIssueObject("TT-51")
def value = issue.getCustomFieldValue(customField);
I have below clarifications
I dono how to retrieve the issue key and copy to custom field?
How to write a condition to trim issue key(e.g TT-41 to TT41) to copy into custom field?