You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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)
}