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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

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

how do i Auto update epic status with epic link issues status with Script runner postfunction

Hi,

I'm trying to change the status of an epic with a post function in script runner.
I'm doing it in the workfow of the issues as a postfunction. I want the epic status to change and go IN PROGRESS when at least one of the epic link issue is IN PROGRESS.

I tryed many way but i can't figure how to do it since i'm not expert in scriptrunner (actualy Altlassian partner in formation)

i find this code but i donc succeed at making it executable as a postfunction...

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.IssueManager;

import com.atlassian.jira.issue.IssueInputParameters;
import com.atlassian.jira.issue.IssueInputParametersImpl;
import com.atlassian.jira.bc.issue.IssueService

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
IssueManager issueManager = ComponentAccessor.getIssueManager();
IssueService issueService = ComponentAccessor.getComponent(IssueService);
CustomField epicLinkField = customFieldManager.getCustomFieldObjectByName('Epic Link');

//hardcode lookup to issue for script console:
MutableIssue issue = issueManager.getIssueObject("TEST-15"); 

IssueInputParameters issueInputParameters = new IssueInputParametersImpl([:]);

//lookup the corresponding epic via the subtask's parent
MutableIssue epic = issueManager.getIssueObject(
    (String)issue.getCustomFieldValue(epicLinkField)
);

// 21 is the transition ID in my workflow
IssueService.TransitionValidationResult validationResult = 
    issueService.validateTransition(epic.getAssignee(), 
    epic.id, 21 as Integer, issueInputParameters)

def errorCollection = validationResult.errorCollection
log.error(errorCollection)
if (! errorCollection.hasAnyErrors()) {    issueService.transition(epic.getAssignee(), validationResult)    log.error("OK")
}
else {    log.error("ERROR")
}

Can you please give me some help ?

Thank you in advance.

Florian

0 answers

Suggest an answer

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

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

273 views 2 5
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