Behaviours validation script not working on create transition

I can't get my behaviours validation script to work when creating transition. It validates fields fine when performing edit on an issue, but on creation it does not take any effect. 

 

(the logic is that if either of the three fields (medicaldevice, exflag, mddProduct) is set to true, the two other fields should be required.)

 

def medicalSite = getFieldByName("Medical Device Site").getValue()
def exFlag = getFieldByName("Ex Product Flag").getValue()
def mddProduct = getFieldByName("MDD Product Flag").getValue()

def deathField = getFieldByName("Did the event lead to or could have lead to death or serious injury")
def hasField = getFieldByName("Has an identifiable event happened")

if (medicalSite == "true" || exFlag == "true" || mddProduct == "true")
{
deathField.setRequired(true)
hasField.setRequired(true)


}

4 answers

Probably I have an idea to my own question. Scripts are getting values that are actually saved on issue - not considering if you change the values in the create screen or any other screen. Then behaviours seems not work for my needs.

0 votes

It's some other problem... it will give you the values on the screen, not the ones saved on the issue.

0 votes

It depends which field that behaviours on - to me it looks like it should be put on all each of the fields that govern whether death is required.

According to this scenario it seems like it takes in consideration only the values that was saved before opening the edit screen: 1. Create issue. (fields are not required even if I check the "MDD Product" flag). However, let's say we don't check any of the flags at this stage. 2. Edit issue, checking MDD Product flag. This should imply that death and has-fields should be required. However the fields are not required when saving issue. 3. Edit issue again. Try to save it - death- and has-fields now get required as intended. (MDD Product field has previously been saved with checked value). Maybe I'm using the script in a way not intended ?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,849 views 12 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot