I am using a web fragement and a REST endpoint and I would like to show a screen letting the user know that the issue has no components, here is an example of the new page I would like to be shown after clicking the button if the issue does not have any components.
Here is my code below:
package SuperFeature
import groovy.transform.BaseScript
import com.atlassian.jira.issue.Issue;
import javax.ws.rs.core.Response
import org.apache.log4j.Logger
import groovy.transform.BaseScript
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import javax.ws.rs.core.MultivaluedMap
import com.atlassian.jira.component.ComponentAccessor
import javax.ws.rs.core.Response
import com.opensymphony.workflow.WorkflowException
@BaseScript CustomEndpointDelegate delegate
mounaGenerate(httpMethod: "GET", groups: ["jira-users"])
{
MultivaluedMap queryParams, String body ->
def log1 = Logger.getLogger("atlassian-jira.log")
def issueId = queryParams.getFirst("issueId") as Long
Issue myissue = ComponentAccessor.getIssueManager().getIssueObject(issueId)
def issueKey = myissue.getKey()
def componentNames = myissue.getComponents()*.name
log1.warn("MOUNA componentNames "+componentNames)
if(componentNames.empty) {
log.warn("MOUNA EMPTY")
// WRITE NEW CODE HERE TO DISPLAY THE NEW PAGE SAYING THAT THE ISSUE
//DOES NOT HAVE COMPONENTS
throw new WorkflowException("Issue does not have components")
}else{
log1.warn("MOUNA componentNames NOT EMPTY")
}
}
Can you please clarify when do you want this Validation to take place? Is it when the issue is being created or when you are transitioning it? I am asking this because, from your description, this seems easier to achieve with either the Behaviour or the Validation rather than using a REST Endpoint.
I am looking forward to your feedback and clarification.
Thank you and Kind regards,
Ram
when a button is clicked but I wanna write the page myself, I am using a web fragment for the button and then I am using a REST api.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.