Python, Beatbox - Return all available fields

1.2k views Asked by At

I'm trying to run a query into Salesforce that returns the names and API names of all the fields with an associated object using beatbox.

Has anyone done this before? Is it possible?

Thanks

3

There are 3 answers

2
superfell On BEST ANSWER

There's an example of that in demo.py that comes with Beatbox,

    desc = svc.describeSObjects("Account")
    for f in desc[sf.fields:]:
        print "\t" + str(f[sf.name])

will print all the API names of the fields on Account, if you want the labels as well, that'd be str(f[sf.label])

1
Johnny V On

The accepted answer results in this error: "TypeError: slice indices must be integers or None or have an index method"

This works:

import beatbox

api = beatbox.PythonClient()  
api.login(sf_username, sf_pw+sf_token)
obj_desc = api.describeSObjects("Order")[0]
names = [name for name in obj_desc.fields]
0
ShaDow RiDeR On

For me this works like a charm :)

I Faced the same error : got "TypeError: slice indices must be integers or None or have an index method"

I got all available fields, labels, data-type easily as : `

import beatbox
api = beatbox.PythonClient()  
api.login(sf_username, sf_pw+sf_token)
fields = api.describeSObjects("Account")[0].fields
all_table_list = [ {'name':key[1].name,'label':key[1].label,'type':key[1].type} for key  in fields.iteritems()]

`