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
Highlighted

Custom script for creating subtask on checkbox field value change Edited

Hi,

I need to create two subtasks when a particular checkbox (custom) field value is checked. I am using Code Runner plugin and Jira version 7.1.6

 

Script used;

 

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

def issueManager = ComponentAccessor.getIssueManager();
//def userManager = ComponentAccessor.getUserManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def cField = customFieldManager.getCustomFieldObject("customfield_14201");
def cFieldValue = issue.getCustomFieldValue(cField);

if (cFieldValue == "Yes") {
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
CommentManager commentMgr = ComponentAccessor.getCommentManager()
commentMgr.create(issue, currentUser, cFieldValue, true)
}

0 comments

Comment

Log in or Sign up to comment
TAGS

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