Archive

Archive for octobre 2009

Displaying custom fields and/or custom field values based on another field in Bugzilla

A long time ago, I promised to write an article on how to display custom fields under certain circumstances… and never wrote it. But as late is better than never, here we go!

One new feature in Bugzilla 3.4 is the ability to display a custom field only when some other field has some given value. For example, let’s say I want to display a custom field named "Impact" only when the priority of bugs is P1. The first thing to do is to create (or edit) the custom field (Administration > Custom Fields > Add a new custom field):

Displaying a custom field only when another field has some given value

Displaying a custom field only when another field has some given value

The important part is on the right of the screenshot. Available fields to depend on are drop-down and multi-select fields and custom fields. Typically, this means the priority, severity, OS, platform, bug status, resolution and the product fields. In our example, "Priority" is selected, and available values for the priority field are automatically listed, from which we can select "P1", as desired. Now, when a bug has priority P1, the Impact custom field will be displayed, else it won’t:

The Impact custom field is only displayed when the priority is P1

The Impact custom field is only displayed when the priority is P1

The change is dynamic, thanks to JS, so you don’t need to reload the page to see the custom field appearing/disappearing. Once you select another priority, the Impact field will immediately disappear from the page, and it will reappear if you re-select P1. (In the screenshot above, I assume you know how to populate values for the Impact field: Administration > Field Values > Impact > Add)

Another cool feature is the ability to decide which values to display in drop-down and multi-select custom fields based on another field value. in our example above, let’s say I want to display values in the Impact field depending on what the severity of the bug is. The first thing is to add this dependency as follows:

Custom field whose values depend on another field

Custom field whose values depend on another field

Compared to the first screenshot, I added the dependency to the severity field. Available fields to depend on are the same as above, i.e. priority, severity, etc…. You then have to either click the "Edit legal values for this field" link on the left of the screenshot, or go to Administration > Field Values > Impact. Then you have to edit each field value which is affected by the severity of bugs:

Restricting when to display a custom field value

Restricting when to display a custom field value

As we added a dependency, a new item has been added when you edit field values. By default, the "Only appears when Severity is set to" field is left empty, meaning that the field value will always be available, independently of the bug severity. Let’s say we want to display the "Global: affects all other components" value of the Impact field only when the bug severity is "blocker". In this case, we edit the value as shown in the screenshot. Let’s also say that we want to display the "Global: affects many other components" value only when the severity is "critical". We edit the value in a similar way to what we did above. Now when you view a bug, you will see something like this:

Restrict the list of available field values

Restrict the list of available field values

The "Global: affects all other components" value is not listed, because the severity of the bug is not "blocker". The "Global: affects many other components" value is listed because the bug severity is "critical". The other two values are listed because I didn’t set any restriction on them, and so they are always available when the Impact field is displayed.

You will probably ask "How do we display the Impact field when the priority is either P1 or P2?". The short answer is that you cannot yet, unfortunately. This is a limitation which we are working on, see bug 479400. Another question could be "How do we display a value when the bug severity is either blocker or critical or major?". The answer is the same as for the previous question: you cannot do this yet, see bug 522971. I hope to see them fixed for Bugzilla 3.6, but the freezing date is pretty close and I fear these features won’t be available on time. Maybe in Bugzilla 3.8!

Catégories:Bugzilla, Mozilla
Suivre

Recevez les nouvelles publications par mail.