Reputation: 1811
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
Upvotes: 0
Views: 1236
Reputation: 71
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()]
`
Upvotes: 0
Reputation: 1238
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]
Upvotes: 0
Reputation: 19040
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])
Upvotes: 2