Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -210,33 +210,33 @@ def interact_with_salesforce(mode, entry_type, quantity, extracted_text):
|
|
| 210 |
|
| 211 |
except Exception as e:
|
| 212 |
return f"❌ Error interacting with Salesforce: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
-
elif mode == "Exit":
|
| 215 |
-
if entry_type == "Sales":
|
| 216 |
-
object_name = "Inventory_Management__c"
|
| 217 |
-
field_name = "Quantity_Sold__c"
|
| 218 |
-
elif entry_type == "Non-Sales":
|
| 219 |
-
object_name = "Un_Billable__c"
|
| 220 |
-
field_name = "Sold_Out__c"
|
| 221 |
-
|
| 222 |
-
# Extract product name
|
| 223 |
-
product_name = match_product_name(extracted_text)
|
| 224 |
-
if not product_name:
|
| 225 |
-
return "Product name could not be matched from the extracted text."
|
| 226 |
-
|
| 227 |
-
query = f"SELECT Id, {field_name} FROM {object_name} WHERE Product_Name__c = '{product_name}' LIMIT 1"
|
| 228 |
-
response = sf.query(query)
|
| 229 |
-
|
| 230 |
-
if response["records"]:
|
| 231 |
-
record_id = response["records"][0]["Id"]
|
| 232 |
-
updated_quantity = quantity
|
| 233 |
-
sf.__getattr__(object_name).update(record_id, {field_name: updated_quantity})
|
| 234 |
-
return f"✅ Updated record for product '{product_name}' in {object_name}. New {field_name}: {updated_quantity}."
|
| 235 |
-
else:
|
| 236 |
-
return f"❌ No matching record found for product '{product_name}' in {object_name}."
|
| 237 |
-
|
| 238 |
-
except Exception as e:
|
| 239 |
-
return f"❌ Error interacting with Salesforce: {str(e)}"
|
| 240 |
# Function to pull structured data from Salesforce and display as a table
|
| 241 |
def pull_data_from_salesforce():
|
| 242 |
try:
|
|
|
|
| 210 |
|
| 211 |
except Exception as e:
|
| 212 |
return f"❌ Error interacting with Salesforce: {str(e)}"
|
| 213 |
+
elif mode == "Exit":
|
| 214 |
+
if entry_type == "Sales":
|
| 215 |
+
object_name = "Inventory_Management__c"
|
| 216 |
+
field_name = "Quantity_Sold__c"
|
| 217 |
+
elif entry_type == "Non-Sales":
|
| 218 |
+
object_name = "Un_Billable__c"
|
| 219 |
+
field_name = "Sold_Out__c"
|
| 220 |
+
|
| 221 |
+
# Extract product name
|
| 222 |
+
product_name = match_product_name(extracted_text)
|
| 223 |
+
if not product_name:
|
| 224 |
+
return "Product name could not be matched from the extracted text."
|
| 225 |
+
|
| 226 |
+
query = f"SELECT Id, {field_name} FROM {object_name} WHERE Product_Name__c = '{product_name}' LIMIT 1"
|
| 227 |
+
response = sf.query(query)
|
| 228 |
+
|
| 229 |
+
if response["records"]:
|
| 230 |
+
record_id = response["records"][0]["Id"]
|
| 231 |
+
updated_quantity = quantity
|
| 232 |
+
sf.__getattr__(object_name).update(record_id, {field_name: updated_quantity})
|
| 233 |
+
return f"✅ Updated record for product '{product_name}' in {object_name}. New {field_name}: {updated_quantity}."
|
| 234 |
+
else:
|
| 235 |
+
return f"❌ No matching record found for product '{product_name}' in {object_name}."
|
| 236 |
+
|
| 237 |
+
except Exception as e:
|
| 238 |
+
return f"❌ Error interacting with Salesforce: {str(e)}"
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
# Function to pull structured data from Salesforce and display as a table
|
| 241 |
def pull_data_from_salesforce():
|
| 242 |
try:
|