Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

[Solved] Groovy Script workflow transition not working as post function Edited

I'm new in groovy script and i try to implement that the workflow status should be changed if a customer field is not empty. If i try to run the script in the groovy console it works as expected but not as post function.

The validation result of the issueService.validateTransition return false but the ErrorCollection mint be empty and returns only the folowing
{code:java}
ERROR [ajp-nio-127.0.0.1-8009-exec-4]: [:]
{code}

Here is my code.

{code:java}

import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.TransitionOptions
IssueService issueService = ComponentAccessor.getIssueService()
Integer actionId = 11 // The transition ID

log.debug("Type ="+issue.getIssueType().getName() +"")
if (issue.getIssueType().getName() != 'Schwachstelle aus PEN Test'){
return
}
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cfSG = customFieldManager.getCustomFieldObject("customfield_14973");
def cfPM = customFieldManager.getCustomFieldObject("customfield_14974");
def sg=issue.getCustomFieldValue(cfSG);
def pm= issue.getCustomFieldValue(cfPM);
if((sg== null || sg=='') && (pm== null || pm=='')){
return
}


def workflowTransitionUtil = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

TransitionOptions transitionOptions = new TransitionOptions.Builder()
.skipConditions()
.skipPermissions()
.skipValidators()
.build()

IssueService.TransitionValidationResult result = issueService.validateTransition(currentUser,
issue.getId(),
actionId,
issueService.newIssueInputParameters(),
transitionOptions)
log.debug("Valid ="+result.isValid() +"")
log.debug("User ="+currentUser +"")
if (result.isValid()) {
issueService.transition(currentUser, result)
} else {
log.error( result.getErrorCollection().getErrors().toString())
}

{code}

can anyone help me finding the reason why?

2 answers

1 accepted

0 votes
Answer accepted
Ismael Jimoh Community Leader Apr 07, 2021

Hi @Hannes Medwed 

Why not write a groovy condition along with using the fast track transition for this?

In your condition, you build the issue type part with the and condition that the custom fields are not empty and when this is fulfilled, perform a fast-track transition to the intended status,

Hi @Ismael Jimoh 

thx for your quick response.

But if i'm not wrong the fast-track transition is a built in part of the Script Runner Pluing and we are using only the MyGrooy Plugin.

I wrote another transition function that works. However, this function is not called after the issue has been created but as a post function to change the status of the sub tasks when the parent task changes to a certain status.

Or am I wrong here and you can give me an example for your explanation?

Best regards
Hannes

Two days spent with my new favorite plugin, some research on the internet and my problem was solved :-)

A fast-track transition exemple ist bundelt with the MyGroovy Plugin in the admin script section

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.3
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

242 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