Behaviour Plugin Priority Field Update Delayed

Mia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2013
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

0 votes
Answer accepted
Christian Czaia _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2013

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...

Christian Czaia _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2013

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...

Mia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 11, 2013

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.

0 votes
Ulrich Nack
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2013
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

0 votes
Christian Czaia _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2013

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...

Suggest an answer

Log in or Sign up to answer