Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -152,6 +152,8 @@ def filter_valid_attributes(attributes, valid_fields):
|
|
| 152 |
|
| 153 |
#π Function to interact with Salesforce based on mode and type
|
| 154 |
|
|
|
|
|
|
|
| 155 |
def interact_with_salesforce(mode, entry_type, quantity, extracted_text):
|
| 156 |
try:
|
| 157 |
sf = Salesforce(
|
|
@@ -202,21 +204,13 @@ def interact_with_salesforce(mode, entry_type, quantity, extracted_text):
|
|
| 202 |
return f"β No matching record found for product '{product_name}' in {object_name}."
|
| 203 |
|
| 204 |
# Handling "Entry" Mode (Creating Records)
|
| 205 |
-
|
| 206 |
-
attributes = {
|
| 207 |
-
"Productname__c": product_name, # Mapping product name
|
| 208 |
-
field_name: quantity # Mapping quantity based on entry type
|
| 209 |
-
}
|
| 210 |
-
# Export data to Salesforce
|
| 211 |
sf.__getattr__(object_name).create(attributes)
|
| 212 |
return f"β
Data successfully exported to Salesforce object {object_name}."
|
| 213 |
-
|
| 214 |
-
except Exception as e:
|
| 215 |
-
return f"β Error interacting with Salesforce: {str(e)}"
|
| 216 |
|
| 217 |
except Exception as e:
|
| 218 |
-
return f"β Error
|
| 219 |
-
|
| 220 |
# Function to pull structured data from Salesforce and display as a table
|
| 221 |
def pull_data_from_salesforce():
|
| 222 |
try:
|
|
|
|
| 152 |
|
| 153 |
#π Function to interact with Salesforce based on mode and type
|
| 154 |
|
| 155 |
+
|
| 156 |
+
# Function to interact with Salesforce based on mode and type
|
| 157 |
def interact_with_salesforce(mode, entry_type, quantity, extracted_text):
|
| 158 |
try:
|
| 159 |
sf = Salesforce(
|
|
|
|
| 204 |
return f"β No matching record found for product '{product_name}' in {object_name}."
|
| 205 |
|
| 206 |
# Handling "Entry" Mode (Creating Records)
|
| 207 |
+
else:
|
| 208 |
+
attributes = {product_field_name: product_name, field_name: quantity}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
sf.__getattr__(object_name).create(attributes)
|
| 210 |
return f"β
Data successfully exported to Salesforce object {object_name}."
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
except Exception as e:
|
| 213 |
+
return f"β Error interacting with Salesforce: {str(e)}"
|
|
|
|
| 214 |
# Function to pull structured data from Salesforce and display as a table
|
| 215 |
def pull_data_from_salesforce():
|
| 216 |
try:
|