Does any one know how i can update the jira screen in a correct way after transition with a goory script.
My script (below) works if i run it from the scriptrunner console and preparing the issue to be in the right position for the transition i would like to do, then the issue looks as it should. after i have ran the script.
But when i run a similar script from the script listener, Fires an event when condition is true.
The issue is transitioned to the right status, but the status value is not changed.
How can i update the issue screen after the transition is done in a correct way with the script?
//-----needed check in listener---------
if (issue.getStatus().getName() == "Installation"){
log.warn("Issue has status Installation")}
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowException
import com.atlassian.jira.bc.issue.IssueService.UpdateValidationResult
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.bc.issue.IssueService
// Get a pointer to the issue
//----Activate if Consloe is used----------------------------------------------------
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("ICTSHH-4917")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
//-------------------------------------------------------------------------------------*/
Issue issueKey = issue
log.warn("issueKey = " + issueKey)
def LinkManagerissue = ComponentAccessor.getIssueLinkManager()
def issueLinks = LinkManagerissue.getInwardLinks(issueKey.getId())
def transitionResult
def workFlowManager = ComponentAccessor.getWorkflowManager()
def workflow = workFlowManager.getWorkflow(issue)
//-----Check what id's are available for transistions
//return workflow.getLinkedStep(issue.getStatus()).getActions().id
def actionId = 421
IssueService issueService = ComponentAccessor.getIssueService()
def transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId,new IssueInputParametersImpl())
def issueInputParameters = issueService.newIssueInputParameters()
//------Check if transittion is possible
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid())
{ log.warn("Transitioned issue $issue through action $actionId") }
else
{ log.warn("The transitionValidation is not valid")}
}
// validate update -------------
UpdateValidationResult updateValidationResult = issueService.validateUpdate(currentUser, issue.getId(), issueInputParameters)
//return UpdateValidationResult
return updateValidationResult.isValid()
/* if (updateValidationResult.isValid()){
// update the issue ----------
issueInputParameters.setStatusId("CUSTOMER ACCEPTANCE")
IssueResult updateResult = issueService.update(currentUser, updateValidationResult)
if (!updateResult.isValid()){
log.warn("error updateResult: " + updateResult.getErrorCollection().toString())}
} else {
log.warn("error: updateValidationResult" + updateValidationResult.getErrorCollection().toString())}
*/
@Tomas Gustavsson I had same issue some time back , below code works for me as "listener" . You can try .
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.workflow.TransitionOptions
import com.atlassian.jira.issue.IssueInputParametersImpl
IssueManager issueManager = ComponentAccessor.issueManager
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
// Test with a single issue on script console, enable below line
// Issue issue = issueManager.getIssueObject("ICTSHH-4917")
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueService issueService = ComponentAccessor.getIssueService()
def issueInputParameters = issueService.newIssueInputParameters()
def transitionOptions= new TransitionOptions.Builder()
.skipConditions()
.skipPermissions()
.skipValidators()
.build()
int actionId = 421
def transitionValidationResult = issueService.validateTransition(user, issue.id, actionId, issueInputParameters,transitionOptions)
if (transitionValidationResult.isValid()) {
def transitionResult = issueService.transition(user, transitionValidationResult)
if (transitionResult.isValid()){
log.debug("Transitioned issue $issue through action $actionId")
}
else {
log.debug("Transition result is not valid") }
}
else {
log.debug("The transitionValidation is not valid")
}
Thanks, unfortunatly i get the same result as befor, the transition values is ok.
But the status for transittion should be "customer acceptance" and is not correct and does not change after refresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
is there a way to set jira workflowStep id?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I just used the above script but it is constantly make JIRA crashed.
Explicitly, enter into transition issue update.
Kindly,
Gilad
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.