Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -225,16 +225,20 @@ def generate_dpr(files):
|
|
225 |
)
|
226 |
|
227 |
if image_content_document_id:
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
238 |
except Exception as e:
|
239 |
salesforce_result += f"Error interacting with Salesforce: {str(e)}\n"
|
240 |
else:
|
|
|
225 |
)
|
226 |
|
227 |
if image_content_document_id:
|
228 |
+
# Link image to the Daily Progress Report record (DPR) using ContentDocumentLink
|
229 |
+
sf.ContentDocumentLink.create({
|
230 |
+
'ContentDocumentId': image_content_document_id,
|
231 |
+
'LinkedEntityId': dpr_record_id, # Link image to DPR record
|
232 |
+
'ShareType': 'V' # 'V' means Viewer access
|
233 |
+
})
|
234 |
+
|
235 |
+
# Now, update the DPR record with the ContentDocumentId in the Site_Images field (if it's a text or URL field)
|
236 |
+
sf.Daily_Progress_Reports__c.update(dpr_record_id, {
|
237 |
+
'Site_Images__c': image_content_document_id # Storing the ContentDocumentId directly
|
238 |
+
})
|
239 |
+
|
240 |
+
salesforce_result += image_upload_result + "\n"
|
241 |
+
|
242 |
except Exception as e:
|
243 |
salesforce_result += f"Error interacting with Salesforce: {str(e)}\n"
|
244 |
else:
|