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

Custom script for creating subtask on checkbox field value change

Princeton Paul November 27, 2018

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
AUG Leaders

Atlassian Community Events