Wiki

Case Status Kiln
Register Log In

Wiki

 
Interact with other plugins us…»Get and Set Another Plugin's B…
  • RSS Feed

Last modified on 1/2/2015 2:29 PM by User.

Tags:

Get and Set Another Plugin's Bug-Joined fields

the CBug GetPluginField() and SetPluginField() methods allow you not only to work with your own plugin's fields but any other plugin's. For example, you can access case fields the user has added with Custom Fields. If you know the field name, you can do this:

CBug bug = api.Bug.GetBug(123);
// use the "sColumnName" of the field from the Plugin_X_CustomField table in the database
string sCaseColor = bug.GetPluginField("customfields@fogcreek.com", "color71");
bug.SetPluginField("customfields@fogcreek.com", "Color71", "green");

Or you can get all the fields added by all plugins with GetAllPluginFields():

string s = "";
CBug bug = api.Bug.GetBug(123);
CStrStrObjTuple[] rgFields = bug.GetAllPluginFields();
foreach (CStrStrObjTuple field in rgFields)
{
    s += HttpUtility.HtmlEncode(field.sFirst) + ", " +
    HttpUtility.HtmlEncode(field.sSecond) + ", " +
    HttpUtility.HtmlEncode(field.oThird == null ? "NULL" : field.oThird.ToString()) + "\r\n";
}

Which gives you something like this for s:

customfields@fogcreek.com, color71, green
KilnPlugin@fogcreek.com, fKilnReview, 0
ProjectBacklog@fogcreek.com, iBacklog, NULL