Hello Team,
i have a requirement where the jira tickets are created in MALIB jira project and MALTR jira project tickets are linked to MALIB.
Now my need is when MALIB jira ticket is transitioned to Fix Pending status, the post function must trigger to transition the linked MALTR tickets to Testing status.
i used some tweeks as below :-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
// Set the key of the target project where linked issues will be transitioned to "Testing" def targetProjectKey = "MALTR"
// Get the current issue and its links
def issue = issue
def linkManager = ComponentAccessor.getIssueLinkManager()
def issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)
// Get the link type for "relates to" issues
def linkType = issueLinkTypeManager.getIssueLinkTypesByName("relates to").find { it.outward == "is related to" }
if (linkType) { // Get all linked issues def linkedIssues = linkManager.getOutwardLinks(issue.getId()).findAll { it.issueLinkType.id == linkType.id }*.destinationObject
// Transition linked issues in the "MALTR" project to the "Testing" status linkedIssues.each { linkedIssue -> def targetProject = linkedIssue.getProjectObject()
if (targetProject && targetProject.key == targetProjectKey)
{
def workflowManager = ComponentAccessor.getWorkflowManager() def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def transitionValidationResult = workflowManager.getWorkflowTransition(linkedIssue, 10763) // Replace 31 with the ID of the transition to "Testing" status
if (transitionValidationResult.isValid())
{ def transitionResult = issueService.transition(user, transitionValidationResult)
if (!transitionResult.isValid())
{ log.error("Transition failed for issue ${linkedIssue.key}: ${transitionResult.errorCollection}")
}
}
}
}
However, this postfunction script is not moving the tickets on MALTR linked tickets to Testing status, please help to let me know how can i resolve this.