I am new to accessing Salesforce data via the API. I am using the beatbox library for Python.

My code:

import beatbox

sf = beatbox.PythonClient()
sf.login('my user name', 'my password + security token')

a = sf.describeSObjects('account')
account = a[0]
accountFields = account.fields

for i in accountFields:
    print i

This gives me a nice list of the fields in Account object. I cannot figure out how to look up the data type for each field, however. I've tried many different iterations based on the examples in the Salesforce API documentation, but not having any luck.

For example, in this code:

for i in accountFields:
    print i.type

my iterations result in the Python string representation of the field, as opposed to Field object of the describeSObjectresult.

1 Answer 1


In beatbox, sObject.fields is a python dict containing Field objects. Your existing command is only getting the keys of the dict, which is the field name. Try this:

# the syntax is `for key, value in dict.items()`
for fieldname, fieldspec in account.fields.items():
    print("Type of", fieldname, "is: ", fieldspec.type)     # Python 3.x syntax

You can see a list of the field data supported by beatbox by looking at the source code.

  • 1
    That print syntax also works in Python 2.7
    – RichVel
    Jun 16, 2013 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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