Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -90,17 +90,20 @@ def create_salesforce_record(name, email, phone_number):
|
|
90 |
'Email__c': email, # Custom email field
|
91 |
'Phone_Number__c': phone_number # Custom phone number field
|
92 |
})
|
93 |
-
|
94 |
# Log the full response from Salesforce
|
95 |
print(f"Salesforce response: {customer_login}")
|
96 |
|
97 |
# Check if the response contains an ID (successful creation)
|
98 |
-
if
|
99 |
print(f"Record created successfully with ID: {customer_login['id']}")
|
100 |
return customer_login
|
101 |
else:
|
102 |
# Log detailed information if the record creation failed
|
103 |
print(f"Record creation failed. Full response: {customer_login}")
|
|
|
|
|
|
|
104 |
return {"error": f"Record creation failed. Full response: {customer_login}"}
|
105 |
except Exception as e:
|
106 |
# Catch and log any exceptions during record creation
|
|
|
90 |
'Email__c': email, # Custom email field
|
91 |
'Phone_Number__c': phone_number # Custom phone number field
|
92 |
})
|
93 |
+
|
94 |
# Log the full response from Salesforce
|
95 |
print(f"Salesforce response: {customer_login}")
|
96 |
|
97 |
# Check if the response contains an ID (successful creation)
|
98 |
+
if 'id' in customer_login:
|
99 |
print(f"Record created successfully with ID: {customer_login['id']}")
|
100 |
return customer_login
|
101 |
else:
|
102 |
# Log detailed information if the record creation failed
|
103 |
print(f"Record creation failed. Full response: {customer_login}")
|
104 |
+
# Log any errors if the response contains 'errors'
|
105 |
+
if 'errors' in customer_login:
|
106 |
+
print(f"Salesforce errors: {customer_login['errors']}")
|
107 |
return {"error": f"Record creation failed. Full response: {customer_login}"}
|
108 |
except Exception as e:
|
109 |
# Catch and log any exceptions during record creation
|