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") }
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.