Restrict creating sub task unless parent task field is set to some value

Hi,

I need to restrict users from creating a sub task until a value in the parent it set to 'Yes'.

I am using the following on the validator for the Create Issue transition on the subtask. It doesnt allow me to create the subtask even when parent it set to 'Yes' :

transientVars["issue"].getCustomFieldValue("custom field name") == 'Yes'

Is there a way to do this?

 

Thank you in advance.

1 answer

This widget could not be displayed.

Hrm... your code is not checking the parent issue though.

The intuitive answer would be to use a validator something like this:

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("My Custom Field")
issue.parentObject.getCustomFieldValue(cf) == "Yes"

but I don't think that's going to work, because the link between parent and child won't be created until after the issue is committed.

But you can try it. I suspect it will give a null reference error, as parentObject will be null.

PS:

issue.parentObject.getCustomFieldValue(cf) == "Yes"

is only correct for getting text field values, if it's a select list or radios use:

issue.parentObject.getCustomFieldValue(cf)?.value == "Yes"

I think I would use the "behaviours" aspect of script runner to put a red warning on the form and make all fields read-only. JIRA really needs permissions per issue type.

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

55 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you