How to use customfields in my plugin ? - FogBugz Knowledge Exchange most recent 30 from http://fogbugz.stackexchange.com2013-05-22T21:09:34Zhttp://fogbugz.stackexchange.com/feeds/question/2571http://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://fogbugz.stackexchange.com/questions/2571/how-to-use-customfields-in-my-pluginHow to use customfields in my plugin ?Unknown2010-03-29T18:46:03Z2012-09-21T20:32:35Z
<p>Hi,</p>
<p>I'm working on a plugin and I would like to get the data from custumfield plugin. </p>
<p>In a perfect world, the user will be able to specified the columns he wants in configurations file or with check boxes. I saw that we can join tables to a bug using the IPluginBugJoin but I'm getting and error</p>
<p>"FogCreek.FogBugz.Exception.FogBugzException: is not a valid table to include in a SQL join, because it is not part of this plugin's schema."</p>
<p>Here's my code:</p>
<pre><code>public string[] BugJoinTables()
{
return new string[] { api.Database.PluginTableName("CustomFields@fogcreek.com", "custombugdata")};
}
</code></pre>
<p>And I try to get the data with something like</p>
<pre><code>sVariable = Bug.GetPluginField("customfields@fogcreek.com", "sColumnName").ToString();
</code></pre>
<p>Thanks</p>
http://fogbugz.stackexchange.com/questions/2571/how-to-use-customfields-in-my-plugin/2577#2577Answer by Brett Kiefer for How to use customfields in my plugin ?Brett Kiefer2010-03-30T00:38:51Z2012-09-21T20:32:35Z<p><strong>Update 1</strong>: as of FogBugz 8, plugins can access other plugins via the CAllPluginsApi, <a href="https://developers.fogbugz.com/default.asp?W184" rel="nofollow">documented here</a>.</p>
<p><strong>Update 2</strong>: Fog Creek authored plugins now run in the FogBugz app domain, so the CAllPluginsApi will likely fail to get you access to Custom Fields as your plugin will not be in the FogBugz app domain. Use <a href="https://developers.fogbugz.com/default.asp?W210" rel="nofollow">this method instead</a>.</p>
<hr>
<p>As of the current version of the FogBugz Plugin API, a plugin cannot access a table (or really any other data) belonging to another plugin. If you are simply trying to use Custom Fields to create a field that your plugin needs, then the thing to do is to use the BugField library (see [your FogBugz install]/PluginUtils), which makes adding new fields to cases really easy. If you really do need to access CustomFields data, please tell us a little more about your use case, or email customer-service@fogcreek.com if you don't want to discuss it in this forum.</p>
http://fogbugz.stackexchange.com/questions/2571/how-to-use-customfields-in-my-plugin/2615#2615Answer by Unknown for How to use customfields in my plugin ?Unknown2010-04-02T18:32:41Z2010-04-02T18:32:41Z<p>I get the answer while I was trying to solve another problem....</p>
<p>Customfields are automatically Join when you use CBugQuery, but you have to add the select.</p>
<pre><code>CBugQuery bugQuery = api.Bug.NewBugQuery();
bugQuery.AddSelect("customFieldColumnName");
CBug[] bugs = bugQuery.List();
</code></pre>
<p>How can we get the sColumnName from the customFields table ?</p>
<p>This is the only thing I need now.</p>