Default Values for POP3 Issues

Topics: General
Nov 21, 2012 at 5:04 PM

Hi,

I just wanted to share this information with others in case it is of interest. If you are wondering how new issues, sent by e-mail and received using BugNET's POP3 polling system, are created, it occurs in BugNET.BLL's IssueManager.cs module in the GetDefaultIssueByProjectId function. What is important to know is that the [0] element is assumed to be the default for these:

var defCat = cats[0];
var defStatus = statuses[0];
var defPriority = priorities[0];
var defIssueType = issueTypes[0];
var defResolution = resolutions[0];
var defAffectedMilestone = affectedMilestones[0];
var defMilestone = milestones[0];


Populating the cats collection is the result of a stored procedure, defined in SqlDataProviderConstants.cs (under Library | Providers). There you will see a reference to "BugNet_ProjectCategories_GetCategoriesByProjectId". If you run that sp in SSMS and pass in the project ID (get that by looking at the Projects table), then you will see your categories:

 exec dbo.BugNet_ProjectCategories_GetCategoriesByProjectId 1

That stored procedure is returning Categories by CategoryName, which means that the Category ID that has a Name first in alphabetical order will be your "default" Category for new issues. In my case I had Enhancement Request, Question, and Suspected Bug (probably not perfect choices, but I'm still testing) and therefore Enhancement Request is my default category for new issues coming in from POP3. I suspect that the other collections (Status, Priority, etc.) are also being alphabetized and the first item in the list is being used as the default.

As a work-around, one thing to do is to rename your default category using a leading asterisk (*). For instance, if you want "Suspected Bug" to be the default then call it "*Suspected Bug".

I think an enhancement to these tables would be to have a bona-fide "Default" column of type Boolean/Bit so that a Value for a given project can be identified as the default value. Of course adding this later would potentially throw-off the existing defaults but that can be explained in the upgrade notes.

Regards,
-- Jon 

Nov 21, 2012 at 5:06 PM

Oh, just adding: Another thought is to name your Categories (or Statuses, etc.) with leading numbers, such as:

01 - Suspected Bug
02 - Enhancement
03 - Question

In this case the "01" item would always sort first and will be the "default" (you could make it 00 also).

This is probably a better idea than using a leading asterisk...

-- Jon 

Nov 21, 2012 at 5:19 PM

Personally when it comes to default values since most of the fields on an issue allow NULL values that would be the default rather than implementing default value code.  This since the default value could be different based on where or who creates the issue that might be an issue for workflow.

My $0.02

Nov 21, 2012 at 6:19 PM

Perhaps I don't understand fully. For example, I didn't want to use Milestones in my project so I had none defined but that caused an error when processing inbound POP3 issues. So I had to create one milestone and give it a name. How would I specify a NULL milestone using the BetNET UI?

Nov 21, 2012 at 6:36 PM

Yeah at one time most of the dropdown items for an issue might have been required (I am assuming), the mailbox reader code assumes that it is so it expects a milestone (as well other fields).

Nov 21, 2012 at 11:36 PM

Correct, at one time values were required but now all the values accept null values.