Using FogBugz On Demand? We've recently rolled out a new sidebar as part of taking FogBugz forward. Please see this article for details on what's new, what's changed, and where you can find all your favorite things.

FogBugz 8

As of FogBugz 8.0, you can now get and set plugin values (Custom Fields plugin or another such as Project Backlog or Kanban) on cases if you know their super-secret (long) name. You can get values if you only know part of the name, which will also then tell you the long name.

Example:

I have a custom field called “adada” and the Project Backlog plugin. I issue an API request:

api.asp?token=[secret]&cmd=search&q=144&cols=sTitle,sCategory,adada,backlog

I get back some XML:

<?xml version="1.0" encoding="UTF-8"?><response>
  <casescount="1">
    <caseixBug="144"operations="edit,spam,assign,resolve,reply,forward">
      <sTitle><![CDATA[Godkänna CleanCash]]></sTitle>
      <sCategory><![CDATA[Inquiry]]></sCategory>
      <adada>123123</adada>
      <plugin_customfields_at_fogcreek_com_adadai67>
        123123
      </plugin_customfields_at_fogcreek_com_adadai67>
      <backlog>1</backlog>
      <plugin_projectbacklog_at_fogcreek_com_ibacklog>
        1
      </plugin_projectbacklog_at_fogcreek_com_ibacklog>
    </case>
  </cases></response>

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):

api.asp?token=[secret]&cmd=edit&ixBug=144&sTitle=hello&plugin_customfields_at_fogcreek_com_adadai67=45

Important:

  • If you want to get all the custom fields you have setup, use cols=plugin_customfields.
  • When querying a custom field via the XML API, you’ll need to substitute an ‘x’ for each space or special character (such as ‘?’) in the custom field name. For example, “My Field 1” should be “MyxFieldx1” when used with cols.
  • The name of the custom field used with cols always matches the first name 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 original name when used with cols.

Known Issues as of FogBugz 8.8.49:

Note that you cannot set or Date or Date and Time type field via the XML API. Searching on Date or Date and Time custom fields via the XML API is not currently supported.


FogBugz 7

Retrieving

This is not possible in FogBugz 7.

New Case Creation

To set the custom field value for a new case via the XML API you should be able to use the following method. Note that this is not an official API feature, so it may not work under all circumstances.

  1. Create your new custom field
  2. Bring up the new case page and use Firebug or the Chrome Inspector 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.
  3. Pass this argument along to the XML API for your request. For example: http://…/api.asp?token=xxx&cmd=new&sTitle=test&P7_severityI61=newseverity

Editing a Case

To edit the custom field value for an existing case, the above method does not work.