17

9

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 cols=ixBug,fOpen,ixPersonAssignedTo,sTitle,hrsCurrEst,dtDue,sStatus,sWeight and it returns everthing but weight.

Thanks

Fog Creek Case FC2192759

flag

1 Answer

9

Future Version

We've added a new method, listCustomFields, 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 XML API Documentation for further updates.

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>
  <cases count="1">
    <case ixBug="144" operations="edit,spam,assign,resolve,reply,forward,remind">
      <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@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 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.

FogBugz 7


Retrieving

This is not possible in FogBugz 7.

New Case Creation

To set the custom field value for a new case, this is currently not supported, but should work just fine.

  1. Add your custom field
  2. 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.
  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.

link|flag
@adambox, you forgot replacing two more dots: fogcreek.com_ibacklog – Michel de Ruiter Apr 26 2011 at 9:53

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.