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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

803 views 2 19
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