Created
June 11, 2018 22:14
-
-
Save joefusaro/37f35dca4a0931cac3b054f7509a4120 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from utils import SalesforceUtility | |
username = 'joe.fusaro@ivanti.com' | |
password = 'myPassword' | |
token = 'mySecurityToken' | |
if __name__ == "__main__": | |
sfdc = SalesforceUtility(username, password, token) | |
client = sfdc.connection | |
members = client.query( | |
"""SELECT Id, Historical_Responded_Date__c, | |
Campaign.StartDate, Status | |
FROM CampaignMember | |
WHERE CampaignId='7011B000002R6LwQAK' AND | |
Status='No Show' AND | |
Historical_Responded_Date__c = NULL | |
""") | |
print("\n\n\nUpdating {} records\n\n\n".format(members['totalSize'])) | |
for member in members['records']: | |
client.CampaignMember.update( | |
member['Id'], | |
{'Historical_Responded_Date__c':member['Campaign']['StartDate']} | |
) | |
print('Updated {}\n'.format(member['Id'])) | |
print('-'*10 + 'COMPLETE' + '-'*10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from simple_salesforce import Salesforce | |
# set sys encoding=utf8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
class SalesforceUtility(object): | |
def __init__(self, username, password, security_token): | |
self.username = username | |
self.password = password | |
self.security_token = security_token | |
self.connection = self.connect() | |
def connect(self): | |
return Salesforce( | |
username=self.username, | |
password=self.password, | |
security_token=self.security_token | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment