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

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 Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

426 views 3 18
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