Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
def versionIdProductionMaintenance = "10214"
def actionName = "Create"

if (getActionName() != actionName) {
    return // not the initial action, so don't set default values
} 

//def issueType = getFieldById("10402").getValue().toString()
def issueType = issueContext.issueType.name

if(issueType == "Change Request") {
//get fixVersion ID
def fixVersionsFieldCR = getFieldById("fixVersions")
//set fixVersion value
def fixVersionsNewValueCR = fixVersionsFieldCR.setFormValue([versionIdProductionMaintenance])
} else {
    def fixVersionsField = getFieldById("fixVersions")
    def fixVersionsNewValue = fixVersionsField.setFormValue("")
}

9. Adding a comment to the linked issue and the main issue-Server

Code Block
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.link.IssueLink;

import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.user.ApplicationUser;

CommentManager commentMgr = ComponentAccessor.getCommentManager()
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser

IssueManager im = ComponentAccessor.getIssueManager();
MutableIssue issue = im.getIssueObject("SP-5519");

def lastComment = commentMgr.getComments(issue).last().body


//def links = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId())
def links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())

//return links[0].getSourceObject()

def output = ""
for( l in links) {
    
    //use this for Outward links
  output = output + l.issueLinkType.name + ": " +  l.getDestinationObject() + "<br/>"
   
    //use this for Inward links
        //output = output + l.issueLinkType.name + ": " +  l.getSourceObject() + "<br/>"
  // adding comment for the main issue   
   
    commentMgr.create(l.getSourceObject(),currentUser, "Test------------", false) 
    
 // adding comment for the linked issue

    commentMgr.create(l.getDestinationObject(),currentUser, "Test------------", false)
}

return output

...