Skip to content

Commit

Permalink
Fixed demo that runs also on a plain sandbox. superfell#32
Browse files Browse the repository at this point in the history
  • Loading branch information
hynekcer committed Jul 2, 2016
1 parent c66eaa5 commit 18743fd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def search(self):
print(str(r[0]) + "\t: " + str(r[2]))

def upsert(self):
if not any(f[sf.name] == 'ChandlerId__c' for f in svc.describeSObjects("Task")[sf.fields:]):
print("Skipped 'upsert' because the custom external Id field doesn't exist")
return
print("\nupsert")
t = { 'type': 'Task',
'ChandlerId__c': '12345',
Expand Down Expand Up @@ -98,6 +101,9 @@ def update(self):
'Id': self.__idToDelete,
'Name': 'BeatBoxBaby',
'NumberofLocations__c': 123.456 }
if not any(f[sf.name] == 'NumberofLocations__c' for f in svc.describeSObjects("Account")[sf.fields:]):
del a['NumberofLocations__c']
print("Skipped a custom field NumberofLocations__c that doesn't exist")
sr = svc.update(a)

if str(sr[sf.success]) == 'true':
Expand Down Expand Up @@ -153,6 +159,8 @@ def getDeleted(self):
def retrieve(self):
print("\nretrieve")
accounts = svc.retrieve("id, name", "Account", self.__theIds)
if not beatbox.islst(accounts):
accounts = [accounts]
for acc in accounts:
if len(acc._dir) > 0:
print(str(acc[beatbox._tSObjectNS.Id]) + " : " + str(acc[beatbox._tSObjectNS.Name]))
Expand Down

0 comments on commit 18743fd

Please sign in to comment.