Hi Team,
I need help in scriptrunner rest endpoint creation for transition issue.
I have one requirement where using fragment we need to transition issue or transition screen should popup once we click on that fragment, I created the fragment for that, but in rest endpoint creation I am facing issue, please help me to create rest end point to transition issue. If anybody aware please reply as soon as possible.
Regards,
Kavya
Hi @Kavya
In your description, you mentioned:-
I have one requirement where using fragment we need to transition issue or transition screen should popup once we click on that fragment, I created the fragment for that, but in rest endpoint creation I am facing issue, please help me to create rest end point to transition issue. If anybody aware please reply as soon as possible.
I am going to assume that you are trying to Use Web Item to display a dialog box. Please clarify.
Please clarify: Are you trying to trigger this when transitioning the Issue?
It would be helpful if you could share a screenshot of your configuration and the REST Endpoint code so I could review it and provide some feedback.
Thank you and Kind regards,
Ram
Hello ram,
Thank you for your reply!
Yes, we have created the custom web item to display dialog box.
I created one rest endpoint which is shared below(I just copied it from one of the community post) and copied this transition issue rest endpoint link and used in the fragment by selecting "Navigate to link" option.
Actually when I click on the fragment/dialog box it is taking me to the black screen instead it should take me to one of the transition screen, so please help me to correct the rest endpoint code.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import groovy.json.JsonBuilder
// Define the transition function
def transitionIssue = { issueKey, transitionId ->
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey(issueKey)
if (issue) {
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def transitionValidationResult = ComponentAccessor.workflowTransitionUtil.validateTransition(user, issue, transitionId, [])
if (transitionValidationResult.isValid()) {
def transitionResult = ComponentAccessor.workflowTransitionUtil.transition(user, transitionValidationResult)
if (transitionResult.successful) {
return "Issue $issueKey transitioned successfully."
} else {
return "Failed to transition issue $issueKey: ${transitionResult.errorCollection?.toString()}"
}
} else {
return "Failed to validate transition for issue $issueKey: ${transitionValidationResult.errorCollection?.toString()}"
}
} else {
return "Issue $issueKey not found."
}
}
// Define the REST endpoint function
def transitionIssueEndpoint = { req, resp ->
def requestBody = req.JSON
// Extract issueKey and transitionId from the request body
def issueKey = requestBody.issueKey
def transitionId = requestBody.transitionId
// Check if issueKey and transitionId are provided
if (!issueKey || !transitionId) {
resp.setStatus(400)
return new JsonBuilder(["error": "Issue key and transition ID are required."])
}
// Perform the transition
def result = transitionIssue(issueKey, transitionId)
// Respond with the result
new JsonBuilder(["message": result])
}
// Expose the endpoint
//post("/rest/scriptrunner/latest/custom/transitionIssue") { req, resp ->
// transitionIssueEndpoint(req, resp)
//}
transitionIssue(httpMethod: "POST") { req, resp ->
transitionIssueEndpoint()}
request.getParameter(req, resp)
Regards,
Kavya Janiwarad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.