Overview
Custom Fields (and Other Plugin Data) can be read (viewed or listed) and updated (edited) using FogBugz API in the same way as standard FogBugz fields. The key is how to find out the custom fields' internal name (the name by which it is stored in the database).
The same steps apply if you prefer using REST API, just use the appropriate commands (GET, POST) and formats for the parameters (JSON) accordingly.
Solution
The steps to identify the custom fields internal name are:
- Find, using FogBugz UI, a case where the custom field is enabled
- Query the custom columns of that case using the API
- Identify the custom column's long unique internal name from the API response
- Update the custom column using its long internal name
Find a Case with the Custom Field
Using the FogBugz UI, search for a case where you see the custom field enabled. It is not necessary to have data in it, just to be present on the UI. Custom fields can be restricted to given projects.
For the rest of the article, let's assume the given case ID (ixBug) for this case is:
ixBug=1076
Query the Custom Columns
We know the case ID, so we are going to use the viewCase command (instead of using the search command).
https://[yourFogBugz]/api.asp?&token=[secret]&cmd=viewCase&ixBug=1076&cols=sTitle,plugin_customfield
Note in the above command the column names passed to cols
parameter:
- sTitle - just to double check that we are viewing the case we are interested in
- plugin_customfield - will result in listing all custom columns
You will get back an XML response, similar to this:
<response>
<case ixBug="1076" operations="edit,assign,resolve,email">
<sTitle>
<![CDATA[Custom Task containing Custom Date Field]]>
</sTitle>
<plugin_customfields>2021-01-10T09:00:00Z</plugin_customfields>
<plugin_customfields_at_fogcreek_com_customdatefieldxbbxc31>2021-01-10T09:00:00Z</plugin_customfields_at_fogcreek_com_customdatefieldxbbxc31>
<plugin_customfields>
<![CDATA[My Text]]>
</plugin_customfields>
<plugin_customfields_at_fogcreek_com_customtextfieldv22>
<![CDATA[My Text]]>
</plugin_customfields_at_fogcreek_com_customtextfieldv22>
<plugin_customfields></plugin_customfields>
<plugin_customfields_at_fogcreek_com_myfieldj13></plugin_customfields_at_fogcreek_com_myfieldj13>
</case>
</response>
Identify the Custom Column Name
A few notes about custom columns internal name:
- All custom fields start with
plugin_customfields_at_fogcreek_com_
. This is why we used it forcols=plugin_customfields
. - Each space or special character (such as '_', '?') is replaced with an 'x'
- 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 withcols
.
So in our case, for example, we have:
- On the UI the custom date column named: CustomDateField_BB2.
- In FogBugz' internal database it is stored as:
plugin_customfields_at_fogcreek_com_customdatefieldxbbxc31
.
Update the Custom Column
Let's update a date type of custom field from the example above.
https://[yourFogBugz]/api.asp?token=[secret]&cmd=edit&ixBug=1076&plugin_customfields_at_fogcreek_com_customdatefieldxbbxc31=2021-01-10T09:00:00Z
Notice that the date format is ISO8601 as per the FogBugz API General Rules.
Known Issues
Known Issues as of FogBugz 8.8.49:
Searching on Date or Date and Time custom fields via the XML API is not currently supported.