Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,6 +47,24 @@ except Exception as e:
|
|
| 47 |
# Using a temporary directory to save retrieved files
|
| 48 |
temp_dir = tempfile.mkdtemp()
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# Function to retrieve all files from the Salesforce custom object
|
| 51 |
def get_all_salesforce_files(custom_object_api_name):
|
| 52 |
if sf is None:
|
|
|
|
| 47 |
# Using a temporary directory to save retrieved files
|
| 48 |
temp_dir = tempfile.mkdtemp()
|
| 49 |
|
| 50 |
+
def get_all_salesforce_files(custom_object_api_name):
|
| 51 |
+
if sf is None:
|
| 52 |
+
print("Salesforce connection is not initialized.")
|
| 53 |
+
return []
|
| 54 |
+
|
| 55 |
+
# Step 1: Query all record IDs from the custom object, including the Google Drive File ID field
|
| 56 |
+
query_all_records = f"SELECT Id, Google_Fille_ID__c FROM {custom_object_api_name} WHERE Google_Fille_ID__c != NULL"
|
| 57 |
+
try:
|
| 58 |
+
all_records = sf.query(query_all_records)
|
| 59 |
+
if 'records' not in all_records or not all_records['records']:
|
| 60 |
+
print("No records found or records list is empty.")
|
| 61 |
+
return []
|
| 62 |
+
return all_records['records']
|
| 63 |
+
except Exception as e:
|
| 64 |
+
print(f"Error querying Salesforce: {e}")
|
| 65 |
+
return []
|
| 66 |
+
|
| 67 |
+
|
| 68 |
# Function to retrieve all files from the Salesforce custom object
|
| 69 |
def get_all_salesforce_files(custom_object_api_name):
|
| 70 |
if sf is None:
|