Access Custom Fields (or other plugin field such as Backlog) on a case using the XML API - FogBugz Knowledge Exchange most recent 30 from http://fogbugz.stackexchange.com 2013-05-25T01:44:16Z http://fogbugz.stackexchange.com/feeds/question/729 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://fogbugz.stackexchange.com/questions/729/access-custom-fields-or-other-plugin-field-such-as-backlog-on-a-case-using-the Access Custom Fields (or other plugin field such as Backlog) on a case using the XML API Jamey 2009-11-17T20:24:34Z 2013-01-30T16:34:13Z <p>I added the custom field "Weight" (Type = Dropdown) to cases using the custom field plugin. How can I use the XML API to retrieve values assigned to this custom field? I am setting the param <code>cols=ixBug,fOpen,ixPersonAssignedTo,sTitle,hrsCurrEst,dtDue,sStatus,sWeight</code> and it returns everthing but weight.</p> <p>Thanks</p> <blockquote> <p><img src="http://www.gravatar.com/avatar/baf927dcc0b0c5d0f41dece1e575aa0f?s=32&amp;d=identicon&amp;r=PG" alt="Fog Creek"> <a href="http://fogbugz.stackexchange.com/questions/1023/whats-that-kiwi-logo-and-case-number-at-the-bottom-of-my-feature-request" rel="nofollow">Case FC2192759</a></p> </blockquote> http://fogbugz.stackexchange.com/questions/729/access-custom-fields-or-other-plugin-field-such-as-backlog-on-a-case-using-the/751#751 Answer by Michael Pryor for Access Custom Fields (or other plugin field such as Backlog) on a case using the XML API Michael Pryor 2009-11-18T20:05:21Z 2013-01-30T16:34:13Z <h1><em>Future Version</em></h1> <p>We've added a new method, <em>listCustomFields</em>, to the XML API, which should make this much easier. It's been coded and approved for implementation, but it hasn't yet been released. Check the <a href="http://fogbugz.stackexchange.com/fogbugz-xml-api" rel="nofollow">XML API Documentation</a> for further updates.</p> <h1>FogBugz 8</h1> <p><br>As of FogBugz 8.0, you can now <strong>get</strong> and <strong>set</strong> plugin values (<a href="http://www.fogcreek.com/FogBugz/plugins/plugin.aspx?ixPlugin=1" rel="nofollow">Custom Fields</a> plugin or another such as <a href="http://www.fogcreek.com/FogBugz/plugins/plugin.aspx?ixPlugin=3" rel="nofollow">Project Backlog</a> or <a href="http://www.fogcreek.com/FogBugz/plugins/plugin.aspx?ixPlugin=15" rel="nofollow">Kanban</a>) on cases if you know their super-secret (long) name. You can <strong>get</strong> values if you only know part of the name, which will also then tell you the long name.</p> <h2>Example:</h2> <p>I have a custom field called "<strong>adada</strong>" and the Project Backlog plugin. I issue an API request: </p> <p><code>api.asp?token=[secret]&amp;cmd=search&amp;q=144&amp;cols=sTitle,sCategory,adada,backlog</code></p> <p>I get back some XML:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;response&gt; &lt;cases count="1"&gt; &lt;case ixBug="144" operations="edit,spam,assign,resolve,reply,forward,remind"&gt; &lt;sTitle&gt;&lt;![CDATA[Godkänna CleanCash]]&gt;&lt;/sTitle&gt; &lt;sCategory&gt;&lt;![CDATA[Inquiry]]&gt;&lt;/sCategory&gt; &lt;adada&gt;123123&lt;/adada&gt; &lt;plugin_customfields_at_fogcreek_com_adadai67&gt; 123123 &lt;/plugin_customfields_at_fogcreek_com_adadai67&gt; &lt;backlog&gt;1&lt;/backlog&gt; &lt;plugin_projectbacklog_at_fogcreek.com_ibacklog&gt; 1 &lt;/plugin_projectbacklog_at_fogcreek.com_ibacklog&gt; &lt;/case&gt; &lt;/cases&gt; &lt;/response&gt; </code></pre> <p>It includes the name of the key I specified and its long name. Note that there may be duplicates of the short name, so it's better to use the long name. Setting a a value requires using the long name (it's too dangerous to guess):</p> <p><code>api.asp?token=[secret]&amp;cmd=edit&amp;ixBug=144&amp;sTitle=hello&amp;plugin_customfields@fogcreek.com_adadai67=45</code></p> <p><strong>Important</strong>: </p> <ul> <li>If you want to get all the custom fields you have setup, use <code>cols=plugin_customfields</code>.</li> <li>When querying a custom field via the XML API, you'll need to substitute an 'x' for each space in the custom field name. For example, "My Field 1" should be "MyxFieldx1" when used with <code>cols</code>.</li> <li>The name of the custom field used with <code>cols</code> always matches the <em>first name</em> of the custom field. If you change the name of the custom field, although all areas of FogBugz will display the new name, the XML API will still expect the <em>original name</em> when used with <code>cols</code>.</li> </ul> <p><strong>Known Issue</strong>:</p> <p>Note that as of FogBugz 8.8.x, <a href="http://fogbugz.stackexchange.com/questions/7938/bug-cant-set-date-or-datetime-type-custom-fields-via-the-xml-api-when-creating" rel="nofollow">there is a known issue</a> where you cannot set a Date or Date and Time type field via the XML API. This will be fixed in FogBugz 9.</p> <hr> <h1>FogBugz 7</h1> <h2><br>Retrieving</h2> <p>This is not possible in FogBugz 7.</p> <h2>New Case Creation</h2> <p>To <strong>set</strong> the custom field value for a <strong>new</strong> case, this is currently not supported, but should work just fine.</p> <ol> <li>Add your custom field</li> <li>Bring up the new case page and use firebug to inspect the input for your new custom field to get the "name" attribute. It should look like "P7_severityI61". In this case "severity" will be the name of your field and the numbers may be different.</li> <li>Pass this argument along to the XML api for your request. For example: <a href="http://.../api.asp?token=xxx&amp;cmd=new&amp;sTitle=test&amp;P7_severityI61=newseverity" rel="nofollow">http://.../api.asp?token=xxx&amp;cmd=new&amp;sTitle=test&amp;P7_severityI61=newseverity</a></li> </ol> <h2>Editing a Case</h2> <p>To <strong>edit</strong> the custom field value for an existing case, the above method does not work.</p> http://fogbugz.stackexchange.com/questions/729/access-custom-fields-or-other-plugin-field-such-as-backlog-on-a-case-using-the/10908#10908 Answer by Jonathan Jackson for Access Custom Fields (or other plugin field such as Backlog) on a case using the XML API Jonathan Jackson 2012-10-27T22:43:51Z 2012-10-27T22:43:51Z <p>Is this still valid for the plugin? Using an installed version of 8.5.125 and plugin version 1.2.6.0. Both of the following queries don't appear to return the custom field:</p> <p>cmd=search&amp;cols=plugin_customfields,sTitle,sArea,sTags,sPersonAssignedTo</p> <p>cmd=search&amp;cols=sTitle,sArea,sTags,sPersonAssignedTo,ExternalxBugxID</p> <p>(where my custom field is "External Bug ID")</p>