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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,037
Community Members
 
Community Events
176
Community Groups

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
1 vote

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

Atlassian Community Events