I've created a Script Post-Function [ScriptRunner] Function that automatically creates Sub-tasks when a New issue is created in the project.
Now, I want to apply a condition that will only create those Sub-tasks when a specific custom field is set to a specific value, i.e., Project Type (Custom Field) == Project Initiative (dropdown menu option).
Any help would be greatly appreciated!
Did you ever find a solution for this? I am trying to do this now, used a built in code snippet, created an issue where I KNOW it will return true, but it's still not creating the task.
This is my current code (no errors in either the editor or the execution):
cfValues['cf[38901]'] == "developer"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Condition: Which is where I'm wanting to put only Project Type (Custom Field) = "Project Initiative".
Target Issue Type: Sub-task
Subtask Summary: PM Activities - Define/Design
Code:
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.user.util.DefaultUserManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.component.ComponentAccessor
issue.setDescription("For Project Managers to track and report their time against this Initiative. Please make sure to update the 'Original Estimate' field under the 'Time Tracking' tab to acurately estimate the time you'll spend supporting this Initiative.")
MutableIssue myIssue = issue
Project project = myIssue.getProjectObject()
def theComponent = ComponentAccessor.getProjectComponentManager().findByComponentName(project.getId(),'PMO - PMs')
if (theComponent == null) {
theComponent = ComponentAccessor.getProjectComponentManager().create("PMO - PMs","","",0,project.getId())
}
myIssue.setComponent([theComponent])
// set Original Estimate to 10d
issue.setEstimate((Long) 288000)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.