I would like to automatically create link issue to the parent project when is created or a script to get all issues and create the link.
//Import classes you need
import com.atlassian.jira.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.issue.fields.CustomField;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
// Get some additional information you typically need like current user
JiraAuthenticationContext userMgr = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser currentUserObj = userMgr.getLoggedInUser();
//Get an IssueManager. you always need one of those.
IssueManager issueMgr = ComponentAccessor.getIssueManager();
CustomFieldManager fieldmgr = ComponentAccessor.getCustomFieldManager();
MutableIssue issue = issueMgr.getIssueObject("TEST-2") // this is just an example key
//Print stuff. Just assuming you are playing around/learning in the Scriptrunner console.
log.error "";
log.error "The current user is " + currentUserObj.name;
log.error "The current issue ID is " + issue.id;
log.error "The current issue key is " + issue.key;
log.error "The current issue key is " + issue.getProjectId()
I have the issue.id and the projectId, But i don't know how connect.
Thanks
Have a look at https://library.adaptavist.com/entity/create-a-backdated-issue - it does some work with dates as well as creating an issue.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.