|
A special rank field is available to allow you to sort issues using a configurable ranking formula. The rank menu allows you to define the formula used in this calculation. The rank field is just like any other field. It can be added as a column in the main menu and made visible to any of the issue detail screens.
The formula must return a numerical rank which is commonly used for escalation purposes. You can also set the rank to specific values that can be searched for by filters. This is very useful for triggering events, such as overdue items.
When using dates in the formulas, you must remember that dates are calculated down to the millisecond. When you enter a due date, you typically only enter the year/month/day. The system however, stores it down to the millisecond (defaulting to 0's if it has nothing else). Therefore you can not simply compare dates to the current Date() method, as the millisecond at any instance is not going to be 0's.
Formula Examples:
Set rank based on priority:
Default Formula (if empty) is:
(100-mPriority*10)+getElapsedTime()
|
Formula for setting rank to 1 for any issues that have passed their due date.
|
(mRequestedDueDate!=null) ? ( (mRequestedDueDate == new java.util.Date()) ? 1 : 0 ) : 0
|
Formula for setting rank to 1 for any issues that are Open and any issues that were closed in the last X milliseconds.
(ie: last week X=1000ms*60sec*60min*24hours*7days
|
(mCurrentStatus=="Open") ? 1 : (mCurrentStatus=="Closed" && (mDateLastModified.getTime() > new java.util.Date().getTime()-X)) ? 1 : 0
|
note: substitute "X" for "new Long(XL).longValue()" for large numbers (ie: greater than 10 days)
Set rank based on priority, where priority increases (towards 1.0) as time since last modified grows... items that are priority 2 will reach priority 1 in 4 hours, items that are priority 3 will reach priority 2 in 1 day:
@@rint(@@max(1.0, (mPriority - (mPriority==2?(getSecondsSinceLastModified()/14400.0):0.0) - (mPriority==3?(getSecondsSinceLastModified()/86400.0):0.0)))*1000)/1000
|
Custom fields must be referenced using their field ID. For example, the following formula references a custom numerical field with id 21:
|
(mUserFields!=null && mUserFields.get(new Integer(21))!=null) ? mUserFields.get(new Integer("21")) : 0
|
we simply set rank to be the same value as the custom field here!
This formula will set (to 1) any requested due date that matches today:
|
(mRequestedDueDate!=null) ? ( (mRequestedDueDate.getDay() == new java.util.Date().getDay() &&
mRequestedDueDate.getMonth() == new java.util.Date().getMonth() &&
mRequestedDueDate.getYear() == new java.util.Date().getYear()
) ? 1 : 0 ) : 0
|
Quick reference for OGNL:
http://www.ognl.org/2.6.1/Documentation/html/reference.html
Properties/Functions available to FBT Bug (Issue) Struct :
public long mId;
public int mRecordVersion;
public Date mDateEntered;
public String mSubject;
public String mCurrentStatus;
public String mCurrentAssignedTo;
public String mLastModifiedBy;
public Date mDateLastModified;
public String mEnteredBy;
public int mPriority;
public String mProject;
public String mArea;
public String mVersion;
public String mEnvironment;
// Vector of BugEntries...
public Vector mBugHistory;
// New fields for Project Management...
public long mParent;
public Date mRequestedDueDate;
public Date mActualCompletionDate;
public double mEstimatedHours;
public double mActualHours;
public double mPercentComplete;
public int mArchived;
public int mElapsedTime;
public String mNotifyList;
public int mRejectedCount;
public String mUniqueProjectId; // The id with project appended to it...
public Date mClosedDate = null; // Date the issue first went to a closed state
// Hashtable of user defined values...
public Hashtable mUserFields;
// Hashtable of current user defined values (specified in bugentry)
public Hashtable mCurrentUserFields;
Functions:
int countRejects();
Object getUserField(int i);
Object getUserField(UserField uf);
int getElapsedTime();
long getElapsedTimeSeconds();
long getSecondsSinceLastModified();
|