Accueil > Bugzilla, Mozilla > Displaying custom fields and/or custom field values based on another field in Bugzilla

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!

About these ads
Catégories:Bugzilla, Mozilla
  1. 20 octobre 2009 à 6:35  

    Wow, this is a great article! :-) People are so often confused about this, I’m really happy to have something that we can point them to about it now.

    -Max

  2. Photrang
    1 novembre 2009 à 10:32  

    Do you know or have an article about how to import bugs into Bugzilla 3.x? Use XML on Bugzilla page (http://landfill.bugzilla.org/bugzilla-tip-pg/show_bug.cgi?ctype=xml&id=1) and import it to Bugzilla on another system?

    Thanks,

  3. rama
    8 février 2010 à 7:45  

    It’s nice artical. Do you know, how to display custom field value based on the "Component" value selectin?

    • Frédéric Buclin
      23 janvier 2013 à 1:18  

      You need Bugzilla 4.0 for that. Component is listed in the "Field only appears when" menu.

  4. chand
    23 janvier 2013 à 9:12  

    how to add a custom field of date with calendar option to select date in bugzilla bug entry form

    • Frédéric Buclin
      23 janvier 2013 à 1:20  

      Select type = Date/Time and make sure that "Can be set on bug creation" is checked.

  5. thanks
    16 octobre 2013 à 11:26  

    how to add a custom table? I need to display a table of 7 columns in the bugzilla UI page. Could anyone please tell the steps to do that.

    • Frédéric Buclin
      16 octobre 2013 à 11:30  

      You cannot add a custom table. Each column would have its own type anyway. What you can do, though, is to create 7 custom fields and set the sortkey to have them displayed in the order you want.

      • thanks
        16 octobre 2013 à 1:40  

        I have created by editing the edit.html.tmpl file. Could you know how to pull the values from back-end database into the Bugzilla.

  1. No trackbacks yet.

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

Suivre

Recevez les nouvelles publications par mail.