Update app.py
Browse files
app.py
CHANGED
|
@@ -137,9 +137,8 @@ def create_salesforce_record(score, checklist_summary, missing_summary, status,
|
|
| 137 |
summarized_checklist = summarize_text(checklist_summary)
|
| 138 |
summarized_missing = summarize_text(missing_summary)
|
| 139 |
|
| 140 |
-
#
|
| 141 |
-
|
| 142 |
-
logging.info(f"Generated Project ID: {project_id}")
|
| 143 |
|
| 144 |
# Ensure inputs are properly formatted
|
| 145 |
score = float(score) if score is not None else 0.0
|
|
@@ -158,7 +157,7 @@ def create_salesforce_record(score, checklist_summary, missing_summary, status,
|
|
| 158 |
logging.info(f"Setting Alert_Sent__c to: {alert_sent}")
|
| 159 |
escalation_flag = str(bool(escalated)).lower() # Ensure this is also a proper boolean string
|
| 160 |
|
| 161 |
-
# Create the record in Project_Closure_Handover__c without the PDF URL for now
|
| 162 |
record = {
|
| 163 |
"Readiness_Score__c": score,
|
| 164 |
"Checklist_Summary__c": checklist_summary,
|
|
@@ -173,8 +172,8 @@ def create_salesforce_record(score, checklist_summary, missing_summary, status,
|
|
| 173 |
"Logs__c": logs,
|
| 174 |
"Open_Punch_Items__c": open_punch_items,
|
| 175 |
"Punch_List__c": punch_list_text,
|
| 176 |
-
"QA_Report__c": qa_report
|
| 177 |
-
|
| 178 |
}
|
| 179 |
|
| 180 |
logging.debug(f"Attempting to create Salesforce record in Project_Closure_Handover__c with data: {record}")
|
|
@@ -216,14 +215,14 @@ def create_salesforce_record(score, checklist_summary, missing_summary, status,
|
|
| 216 |
else:
|
| 217 |
logging.warning(f"No PDF file found at {pdf_path}. Skipping attachment and URL update.")
|
| 218 |
|
| 219 |
-
return f"Record created successfully. Record ID: {record_id}. PDF attached and URL set to: {pdf_download_url}
|
| 220 |
except simple_salesforce.SalesforceError as e:
|
| 221 |
logging.error(f"Salesforce error while creating Project_Closure_Handover__c record: {str(e)}")
|
| 222 |
logging.error("Possible issues: Object permissions, field-level security, validation rules, or required fields.")
|
| 223 |
logging.error("Check the following in your Salesforce org:")
|
| 224 |
logging.error("- Ensure the user has Create and Edit permission on Project_Closure_Handover__c.")
|
| 225 |
logging.error("- Ensure the user has permission to create and read Attachments.")
|
| 226 |
-
logging.error("- Verify field-level security for all fields in the record
|
| 227 |
logging.error("- Check for validation rules or required fields that might be failing.")
|
| 228 |
return f"Salesforce error: {str(e)}"
|
| 229 |
except Exception as e:
|
|
|
|
| 137 |
summarized_checklist = summarize_text(checklist_summary)
|
| 138 |
summarized_missing = summarize_text(missing_summary)
|
| 139 |
|
| 140 |
+
# Skip Project_ID__c as it's a Lookup field and no valid ID is provided
|
| 141 |
+
logging.info("Skipping Project_ID__c field due to Lookup field type and no user-provided ID")
|
|
|
|
| 142 |
|
| 143 |
# Ensure inputs are properly formatted
|
| 144 |
score = float(score) if score is not None else 0.0
|
|
|
|
| 157 |
logging.info(f"Setting Alert_Sent__c to: {alert_sent}")
|
| 158 |
escalation_flag = str(bool(escalated)).lower() # Ensure this is also a proper boolean string
|
| 159 |
|
| 160 |
+
# Create the record in Project_Closure_Handover__c without the PDF URL or Project_ID__c for now
|
| 161 |
record = {
|
| 162 |
"Readiness_Score__c": score,
|
| 163 |
"Checklist_Summary__c": checklist_summary,
|
|
|
|
| 172 |
"Logs__c": logs,
|
| 173 |
"Open_Punch_Items__c": open_punch_items,
|
| 174 |
"Punch_List__c": punch_list_text,
|
| 175 |
+
"QA_Report__c": qa_report
|
| 176 |
+
# Project_ID__c omitted as it's a Lookup field
|
| 177 |
}
|
| 178 |
|
| 179 |
logging.debug(f"Attempting to create Salesforce record in Project_Closure_Handover__c with data: {record}")
|
|
|
|
| 215 |
else:
|
| 216 |
logging.warning(f"No PDF file found at {pdf_path}. Skipping attachment and URL update.")
|
| 217 |
|
| 218 |
+
return f"Record created successfully. Record ID: {record_id}. PDF attached and URL set to: {pdf_download_url}"
|
| 219 |
except simple_salesforce.SalesforceError as e:
|
| 220 |
logging.error(f"Salesforce error while creating Project_Closure_Handover__c record: {str(e)}")
|
| 221 |
logging.error("Possible issues: Object permissions, field-level security, validation rules, or required fields.")
|
| 222 |
logging.error("Check the following in your Salesforce org:")
|
| 223 |
logging.error("- Ensure the user has Create and Edit permission on Project_Closure_Handover__c.")
|
| 224 |
logging.error("- Ensure the user has permission to create and read Attachments.")
|
| 225 |
+
logging.error("- Verify field-level security for all fields in the record.")
|
| 226 |
logging.error("- Check for validation rules or required fields that might be failing.")
|
| 227 |
return f"Salesforce error: {str(e)}"
|
| 228 |
except Exception as e:
|