Behaviour Plugin Priority Field Update Delayed

I have created a Behaviour to update the Priority based on two custom fields, Impact & Urgency (both are Select Fields).

However, one slight glitchy thing is when I change Impact & Urgency the Priority won't update at first on the issue. I have to go back into 'Edit' and hit 'Update' again for it to trigger the Priority change based on the Behaviour.

My behaviour code is below:

FormField fimpact = getFieldByName("Impact")
FormField furgency = getFieldByName("Urgency")
FormField fpriority = getFieldById(getFieldChanged())
FormField fpriority0 = getFieldById("priority-field")

String Imp = (String) fimpact.getFormValue()
String Urg = (String) furgency.getFormValue()

if (Imp == "10800" && Urg == "10803") {
fpriority.setFormValue("1") 
} else if (Imp == "10800" && Urg == "10804") {
fpriority.setFormValue("2") 
} else if (Imp == "10800" && Urg == "10805") {
fpriority.setFormValue("3") 
} else if (Imp == "10801" && Urg == "10803") {
fpriority.setFormValue("2") 
} else if (Imp == "10801" && Urg == "10804") {
fpriority.setFormValue("3") 
} else if (Imp == "10801" && Urg == "10805") {
fpriority.setFormValue("4") 
} else if (Imp == "10802" && Urg == "10803") {
fpriority.setFormValue("3") 
} else if (Imp == "10802" && Urg == "10804") {
fpriority.setFormValue("4") 
} else if (Imp == "10802" && Urg == "10805") {
fpriority.setFormValue("5") 
}

3 answers

1 accepted

You probably have the code attached to the priority field. Behaviopurs plugin will listen for changes of that field. (A fresh edit will trigger the behaviour...)
If you change the other fields the code won't be triggered. Try using a slightly different code (getFieldChanged won't work) and use that code in both of the fields that are used to trigger the behaviour...

BTW, I would do a check if values are present (sth. like if (!fimpact.getFormValue()|| furgency.getFormValue())
{//exit or log.debug....}

That way you don't mess up your log with error messages if no values are present...

Great, thanks Christian. I didn't think of that. I moved the script into the Impact & Urgency fields and it now updates when they change.

You probably have the code attached to the priority field. Behaviopurs plugin will listen for changes of that field.
If you change the other fields the code won't be triggered. Try using a slightly different code (getFieldChanged won't work) and use that code in both of the fields that are used to trigger the behaviour...

Hi Mia,
I have had a similar problem. For me a reindex of the issue solves the problem. Perhapes ist the same to you. Here a code snipped i used:

public static void indexIssue(final Issue issue) throws IndexException { final IssueIndexManager issueIndexManager = ComponentAccessor.getIssueIndexManager(); final boolean origVal = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); issueIndexManager.reIndex(issue); ImportUtils.setIndexIssues(origVal); }

regards

Uli

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

102 views 0 5
Read article

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