listName='DWM - Export Queue TEST', listType='contacts') exportDef = elq.CreateDef(defType='exports', entity='contacts', fields=fieldset, filters=myFilter, defName=exportDefName, syncActions=[syncAction]) logging.info("export definition created: " + exportDef['uri']) ## Create sync exportSync = elq.CreateSync(defObject=exportDef) logging.info("export sync started: " + exportSync['uri']) status = elq.CheckSyncStatus(syncObject=exportSync) logging.info("sync successful; retreiving data") ## Retrieve data data = elq.GetSyncedData(defObject=exportDef, retrieveLimit=80000) logging.info("# of records:" + str(len(data))) ## Setup logging vars total = len(data) if len(data) > 0: logging.info("Add to 'dwmQueue'") client = MongoClient(os.environ['MONGODB_URL'])
exportDefName = 'Contacts.LeadType - Get Campaign Details ' + str( datetime.now()) cdoDef = elq.CreateDef(defType='exports', entity='customObjects', cdoID=1269, fields=myFields, filters=myFilter, defName=exportDefName) logging.info("export definition created: " + cdoDef['uri']) cdoSync = elq.CreateSync(defObject=cdoDef) logging.info("export sync started: " + cdoSync['uri']) status = elq.CheckSyncStatus(syncObject=cdoSync) logging.info("sync successful; retreiving data") data = elq.GetSyncedData(defObject=cdoDef) logging.info("# of records:" + str(len(data))) if (len(data) > 0): dataOut = data nullCount = 0 sfdcCampaigns = sf.query_all( "SELECT Id, Solution_Code_Family__c, Solution_Code__c FROM Campaign") sfdcCampaignsId = dict((d['Id'], d) for d in sfdcCampaigns['records'])
print(myFields) print("Create a filter for the API") myFilter = elq.FilterExists(name='My Zipcodes to clean', existsType='ContactSegment') print(myFilter) print("Tell the API what we want to export") myExport = elq.CreateDef(entity='contacts', defType='exports', fields=myFields, filters=myFilter, defName="My zipcode export") print("Start syncing the data for export") mySync = elq.CreateSync(defObject=myExport) status = elq.CheckSyncStatus(syncObject=mySync) print(status) print("Get the data...") data = elq.GetSyncedData(defObject=myExport) print( "Data has " + str(len(data)) + " records" ) ## tells you how many records were exported; should match the number from our segment print("First row: ") print(data[0]) ## show us the first row of data print("Clean up the zipcode values") for row in data: if (row['Zip or Postal Code'] != ''): ## Only process if the zipcode field is not blank