Plugin Developer Discussion

Discussion for FogBugz Plugin developers

"Remind" plugin per case

I would like to make the "Remind" function, currently only available to admins, available on the case detail page. I would like to create a "Remind" link at the top of each case (played with the "Assign to Me" plugin for that) that links to a new page that (a) uses the "user auto-complete" box and (b) has a text area with a link to the current case.

Here are my questions:
1. Can I and how can I use the "user auto-complete" box used throughout FogBugz?
2. How do I pass data about the current case, such as the number, title, and url, to the new page to prepare the email title and text area?
3. How do I send the email from FogBugz?
David Smith Send private email
Sunday, August 9, 2009
The bad news first: #3 isn't yet possible.  Making it possible for a plugin to send emails is high on our list of new features for the plugin architecture, but right now we're still fighting bugs from launch.

#1: See the IPluginPageDisplay example (W9) for an example of creating a dropdown.  You'll just want to supply it with a list of users.  To do that, use CPersonQuery:

CPerson[] people = api.Person.NewPersonQuery().List();

#2: You'll need to pass it in the Request parameters.  See W105 for more information on that.  Instead of using a form, though, you'll want to pass the ixBug in the URL:

string sUrl = api.Url.PluginPageUrl() + "&" + api.PluginPrefix + "ixBug=" + bug.ixBug;

In the page linked, you can then do this:

int ixBug;
if (int.TryParse(api.Request[api.PluginPrefix + "ixBug"], out ixBug))
  CBug bug = api.Bug.GetBug(ixBug);

You can use that to get the title and other information

string title = bug.sTitle;
string url = Url.BugViewUrl(bug.ixBug);

#3: As I said, this is not yet possible.  However, if a case is edited then the person it is currently assigned to is automatically notified, so you could edit the case and let that notify the person it is assigned to:

bug.Commit("What is the status of this case?");

That's the best I can do for now.  Hope it helps.
David Fullerton Send private email
Monday, August 10, 2009
Making good progress so far. I can query and display all the users who subscribe to a case, but I am struggling with querying all the users who are not subscribed to a case. Here is my failed query:

var query = api.Database.NewSelectQuery("Person");
query.AddSelect("SFullName, SEmail");
query.AddWhere("IxPerson NOT IN (SELECT IxPerson FROM Subscriptions WHERE IxBug = @IxBug)");
query.SetParamInt("@IxBug", ixBug);
query.IgnorePermissions = true;

FogBugz chokes on the "NOT" in the query ("expected boolean expression, found 'NOT'") and, presumably, it will not like that I stuck the IN clause into the WHERE. How can I write a NOT IN clause as shown in the WHERE clause above?
David Smith Send private email
Wednesday, August 12, 2009
It now occurs to me that I don't want to list out the non-subscribers, though I am still curious how to construct a WHERE NOT IN query.

I can now list the subscribers and, using the following code, I can alert non-subscribers with an email from the users client, seeing as I cannot send email from my plugin:

string content = String.Concat("<a href=\"mailto://?subject=", Url.UrlEncode(String.Concat("(Case ", bug.ixBug, ") ", bug.sTitle)), "&body=",api.Url.BaseUrl(), Url.BugViewUrl(bug.ixBug), "\">New Mail</a>");
return new CBugDisplayDialogItem(id + "Alert", content, "Alert a Nonsubscriber");
David Smith Send private email
Wednesday, August 12, 2009
Hmm, it looks like WHERE NOT IN is not currently possible.  We added a AddWhereIn method, but neglected to make it possible to negate that.  I've opened a case for it.

In the meantime, I think you can work around it using a LEFT JOIN:

CSelectQuery querySub = api.Database.NewSelectQuery("Subscription");
query.AddWhere("ixBug = @ixBug");
query.SetParamInt("ixBug", ixBug);

query.AddLeftJoinSelect(querySub, "Subscription", "Subscription.ixPerson = Person.ixPerson");
query.AddWhere("Subscription.ixPerson IS NULL");
David Fullerton Send private email
Tuesday, August 18, 2009

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz