Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Issue Status Name is not Changing Even after the actual workflow is Changed Edited

Workflow of the issue type:

Screen Shot 2020-10-27 at 3.21.42 PM.png

Status of the workflow: 

Screen Shot 2020-10-27 at 3.14.13 PM.png

I am trying to change the workflow from "Waiting On App Owner Approval" to "In Progress" with a groovy script when there is a change in transition, it Skips "Waiting for PHI Approver" status if the requested application is not a PHI Application. If you see screenshot 2 it is providing with the option of "Access Granted" Button, which means this already moved to "In Progress" Status according to Screenshot 1, not sure why the Status is not changing from "In Progress"(Status in Screenshot 2). Can someone point me if I am made any mistake? 

 

Here is the code I am using: 

 

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.event.type.EventDispatchOption
import org.ofbiz.core.entity.GenericValue
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.issue.fields.CustomField;
import java.util.Date;
import java.util.ArrayList;
import java.util.stream.Collectors;


def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
def issue = issueManager.getIssueObject(event.issue.key)
IssueService issueService = ComponentAccessor.getIssueService()
def actionId = 201
def workflowEntries
def transitionResult
def transitionValidationResult
def StatusId = 6
def customFieldManager = ComponentAccessor.getCustomFieldManager()

if (issue.getIssueType().name == "Application Access Request") {
def status = event.issue.getStatus().getName();
if(status == 'Waiting For PHI Approver'){

def customFieldManager1 = ComponentAccessor.getCustomFieldManager()

def cField = customFieldManager1.getCustomFieldObject("customfield_10628")
def cFieldValue = event.issue.getCustomFieldValue(cField)
String str = cFieldValue.toString()
String str1 = (str) - 'null:' - '1:'
int s = str1.length()
def ApplicationName = (str1.substring(str1.lastIndexOf("[") + 1)).trim() - ']'


if(ApplicationName in ['Strongdm','TriNet']){

def issue1 = event.getIssue() as MutableIssue
ApplicationUser UserName = ComponentAccessor.getUserUtil().getUserObject("timothy.smith")
issue1.setAssignee(UserName);
issueManager.updateIssue(UserName, issue1, EventDispatchOption.DO_NOT_DISPATCH, false)
}
else {

transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId,new IssueInputParametersImpl())
//MutableIssue epic
log.error(transitionValidationResult)
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid())
{ log.error("Transitioned issue $issue through action $actionId") }
else
{ log.error("The transitionValidation is not valid: "
+ transitionValidationResult?.errorCollection?.errorMessages?.join(",")) }
}
else {
log.error("The transitionValidation is not valid: "
+ transitionValidationResult?.errorCollection?.errorMessages?.join(","))
}
}

}
}

2 answers

1 accepted

0 votes
Answer accepted
John Funk Community Leader Oct 27, 2020

Hi Harish - Welcome to the Atlassian Community!

I don't know Groovy very well, but why don't you just use Automation for Jira and then don't have to write code? 

Thanks, Automation for Jira Working as expected. thanks for your suggestion. 

Like John Funk likes this

The code you have posted is for Jira Server/Data Center and will not work in Jira Cloud. As @John Funk has mentioned, using Automation is much better alternative in the Cloud.

Sure Yevgen, Thank you. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

How to log work and track time in Jira when a person is part of multiple teams

  The manager’s daily activities include a list of challenges to reach high levels of efficiency for their teams. Part of these challenges is related to how to deal with the worklog systems sin...

105 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you