Hi,
I want to set the priority for the subtask the same as in the parent task (with the ability to change it when creating the task), but the script does not work
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.web.util.OutlookDate
import com.atlassian.jira.web.util.OutlookDateManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import java.sql.Timestamp
import static com.atlassian.jira.issue.IssueFieldConstants.*
@BaseScript FieldBehaviours fieldBehaviours
FormField field = getFieldById(getFieldChanged())
FormField parent = getFieldById("parentIssueId")
Long parentIssueId = parent.getFormValue() as Long
if (!parentIssueId) {
// this is not a subtask, or the field already has data
return
}
def issueManager = ComponentAccessor.getIssueManager()
def parentIssue = issueManager.getIssueObject(parentIssueId)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
getFieldById("PRIORITY").setFormValue(parentIssue.getPriorityObject().id)
Hi @Yashin Vladislav ,
Your script seems fine, but I think you need to put priority in lower case :
getFieldById("priority").setFormValue(parentIssue.getPriorityObject().id)
That worked on my instance.
Antoine
In my instance don't work :(
getFieldById("priority").setFormValue(parentIssue.getPriorityObject().id)
I check this in Initialiser in behavior!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have been trying this script (in Initializer too) :
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
@BaseScript FieldBehaviours fieldBehaviours
def parent = getFieldById("parentIssueId")
Long parentIssueId = parent.getFormValue() as Long
def issueManager = ComponentAccessor.getIssueManager()
def parentIssue = issueManager.getIssueObject(parentIssueId)
log.error("parentIssue : " + parentIssue)
def parentPriority = parentIssue.getPriorityObject().id
log.error("parentPriority : " + parentPriority.getClass())
log.error("parentPriority : " + parentPriority)
getFieldById("priority").setFormValue(parentPriority)
and it has been working fine. I am using jira 7.6.0 with scriptrunner 5.4.12. If you are using server side script, maybe try a direct script.
Antoine
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.
I am sorry, I thought it was in the Initializer, but it actually is bound to the Issue Type field :
Antoine
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.