1

1

Is it possible to resolve and close a case from the plugin API?

I don't see any related methods/etc in the documentation.

The only thing I could think to do is to make a call to the XML api from the plugin... but I would prefer to avoid this.

Fog Creek Case FC1919325

flag

1 Answer

0

Resolve and close a case:

int ixbug = 75;
CBug bug = api.Bug.GetBug(ixbug);

// 11 is Resolved (Responded) for my installation. you'll need to
// make sure the status is valid for the case, check the Schema*
// for the Status table.
bug.ixStatus = 11;
bug.Commit("resolved by plugin");
bug.fOpen = false;
bug.Commit();

I'm not sure if there's an easier way to get the ixStatus for a status you want than running a CStatusQuery... Here's a sample query that will return all the valid statuses for the case in question. You would want to make sure your code uses the right one for any case it's given.

int ixCategory = bug.ixCategory;

CStatusQuery query = api.Status.NewStatusQuery();
query.IgnorePermissions = true;
query.AddSelect("Status.sStatus, Status.ixStatus, Status.ixCategory");
query.AddWhere("Status.fResolved = 1");
query.AddWhere(string.Format("Status.ixCategory in ({0}, {1})", ixCategory, -1));
DataSet ds = query.GetDataSet();
foreach (DataRow row in ds.Tables[0].Rows)
{
     // do something
}

*DB Schema

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.