I'm probably going to regret posting this. It's late and I know this code is buggy. I've been playing with the Force.com library for the Google App Engine. You can fine the details at Salesforce.com.

You'll need to log into your google account to take a look at this. It opens in a new window.

http://mamoo.appspot.com/bloggie_sf_ipod

I tried to make it ipod friendly, but it's not that great. I still haven't downloaded the webapp helper stuff from apple.

Here are a few things to take a look at:


  • It's using the asynch library I wrote. Again, not great but it's simple.
  • It's accessing both the account and lead objects.
  • You can search for accounts just like you can with the example they provide. The SOQL is the same as the sample code the provide with the kit though the handler code is different. Try searching for 'd'. It'll give you some results.
  • The lead section does a couple of things. First it displays the lead form. Notice the Industry dropdown is displaying the picklist from the lead object.
  • After the lead entry form is display and using a callback we request gae to retrieve the last five leads created.

In case you are interested, here is the method that pulls the picklist out of Lead. It took a little playing around to get it to work. I'm still learning python and there aren't that many Force.com API examples floating around in Python.


def getIndustryPickList(self):
industryPickList = list()
self.sforce = beatbox.PythonClient()
sfl = SalesforceLogin()
try:
login_result = self.sforce.login(sfl.username(), sfl.password() sfl.token())
except beatbox.SoapFaultError, errorInfo:
return industryPickList
objectResults = self.sforce.describeSObjects('Lead')
for objectResult in objectResults:
field = objectResult.fields['Industry']
if field is not None:
for plv in field.picklistValues:
if plv['active']:
pick = GenericObject()
pick.label = plv['label']
pick.value = plv['value']
pick.defaultValue = plv['defaultValue']
industryPickList.append(pick)

return industryPickList

The Industry field exists as a dictionary object in the fields attribute of the Lead object description. The picklistValues exist as an array of dictionary values on the Industry field. Finally each picklist attribute (name, value, active, etc.) exists as an item in the dictionary.

 
 User
top comments
 
top views
 
top tags
 
favorite sites