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 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,864 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