How to Add Formulas to Custom User Fields

  • Thursday, May 19, 2011
  • FIT has always offered a Rank formula which allows the administrator to configure Rank to show a calculated value for each issue, based on the states of issues, or based on the values of specific fields for an issue.


    The most common use for the Rank field is to create an escalation order for issues based on a combination of :
    A) the priority of the issue, and
    B) how long the issue has been sitting open


    This way, a quick report can be made using the Rank field to order the issues.
    Any issues which have been sitting more than X days will become more important.


    The value for Rank is calculated using an OGNL formula, which allows us to use the values for fields of each bug structure, or methods defined in the BugStruct class, to make a custom calculation. For example, the default Rank formula :
    (100-mPriority*10)+getElapsedTime()


    This formula calculates an escalation value where any issue that is open for more than 10 days will escalate to a rank of a new issue in the next Priority scale.
    This is very useful but it is limited in that it only allows one calculation.


    With Version 8.03+, a few new classes have been created as part of the base code set for FIT. These are :
    FormulaCustomUserField - create a custom formula showing a Double value
    FormulaIntCustomUserField - create a custom formula showing an Integer value
    FormulaDateCustomUserField - create a custom formula showing a Date value

    Each of these new class types can be very useful to create your very own custom field.

    Note the new custom option in the Advanced settings of the Admin -> Custom Fields menu.
    Generally, this is used for classes that are created by our team as an add-on feature.

    These Formula types allow you to use the OGNL functionality as a formula for a readonly calculated field type which you can use for reports, other calculations, etc.

    As an example, one custom recently inquired about how to include the date that an issue was closed. Unfortunately, the Closed Date is not an existing default field in the system. However, the data does exist for the calculation of the ElapsedTime (time until closed) field.

    The new FormulaDateCustomUserField allows us to define a new field called "CLOSED DATE" which will simply take the value of the mClosedDate field, which is in the system. The formula in this case is very simple, but it shows how useful the field can be.

    The following images show the configuration option :






    and the resulting details for a given issue:


    We appreciate that OGNL can be complicated but we do list the BugStruct fields as part of the Rank documentation. Also, you are free to discuss with us if you are not sure, but you think this field could be of use to you.

    0 comments:

    Post a Comment