Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -78,11 +78,11 @@ except Exception as e:
|
|
| 78 |
# Function to create Salesforce record
|
| 79 |
def create_salesforce_record(name, email, phone_number):
|
| 80 |
try:
|
| 81 |
-
# Attempt to create a record in Salesforce
|
| 82 |
customer_login = sf.Customer_Login__c.create({
|
| 83 |
-
'Name': name,
|
| 84 |
-
'Email__c': email,
|
| 85 |
-
'Phone_Number__c': phone_number
|
| 86 |
})
|
| 87 |
|
| 88 |
# Log the full response from Salesforce
|
|
@@ -93,14 +93,15 @@ def create_salesforce_record(name, email, phone_number):
|
|
| 93 |
print(f"Record created successfully with ID: {customer_login['id']}")
|
| 94 |
return customer_login
|
| 95 |
else:
|
| 96 |
-
print(f"Record creation failed: {customer_login}")
|
| 97 |
-
return {"error": "Record creation failed
|
| 98 |
except Exception as e:
|
| 99 |
# Catch and log any exceptions during record creation
|
| 100 |
error_message = str(e)
|
| 101 |
print(f"Error creating Salesforce record: {error_message}")
|
| 102 |
return {"error": f"Failed to create record in Salesforce: {error_message}"}
|
| 103 |
|
|
|
|
| 104 |
@app.route("/")
|
| 105 |
def index():
|
| 106 |
return render_template("index.html")
|
|
|
|
| 78 |
# Function to create Salesforce record
|
| 79 |
def create_salesforce_record(name, email, phone_number):
|
| 80 |
try:
|
| 81 |
+
# Attempt to create a record in Salesforce with correct field API names
|
| 82 |
customer_login = sf.Customer_Login__c.create({
|
| 83 |
+
'Name': name, # Standard field (name)
|
| 84 |
+
'Email__c': email, # Custom email field
|
| 85 |
+
'Phone_Number__c': phone_number # Custom phone number field
|
| 86 |
})
|
| 87 |
|
| 88 |
# Log the full response from Salesforce
|
|
|
|
| 93 |
print(f"Record created successfully with ID: {customer_login['id']}")
|
| 94 |
return customer_login
|
| 95 |
else:
|
| 96 |
+
print(f"Record creation failed. Full response: {customer_login}")
|
| 97 |
+
return {"error": f"Record creation failed. Full response: {customer_login}"}
|
| 98 |
except Exception as e:
|
| 99 |
# Catch and log any exceptions during record creation
|
| 100 |
error_message = str(e)
|
| 101 |
print(f"Error creating Salesforce record: {error_message}")
|
| 102 |
return {"error": f"Failed to create record in Salesforce: {error_message}"}
|
| 103 |
|
| 104 |
+
|
| 105 |
@app.route("/")
|
| 106 |
def index():
|
| 107 |
return render_template("index.html")
|