Rammohan0504 commited on
Commit
eb71bff
·
verified ·
1 Parent(s): 45e6457

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -225,16 +225,20 @@ def generate_dpr(files):
225
  )
226
 
227
  if image_content_document_id:
228
- image_content_document_ids.append(image_content_document_id)
229
-
230
- # Now, link the image to the DPR record in the correct field (e.g., Site Images)
231
- # Assuming you have a field like `Site_Images__c` in the DPR record that accepts ContentDocumentId
232
- sf.Daily_Progress_Reports__c.update(dpr_record_id, {
233
- 'Site_Images__c': image_content_document_id # Store ContentDocumentId in Site_Images__c field
234
- })
235
-
236
- salesforce_result += image_upload_result + "\n"
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: