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