Rammohan0504 commited on
Commit
dd75a4a
·
verified ·
1 Parent(s): 9e8c5e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -137,9 +137,10 @@ def upload_file_to_salesforce(file_path, filename, sf_connection, file_type):
137
  )
138
  content_document_id = content_document['records'][0]['ContentDocumentId']
139
 
140
- # Fix URL generation to avoid duplicate salesforce.com in the URL
141
  content_document_url = f"https://{sf_connection.sf_instance}.salesforce.com/{content_document_id}"
142
-
 
143
  return content_document_id, content_document_url, f"File {filename} uploaded successfully"
144
  except Exception as e:
145
  return None, None, f"Error uploading {filename} to Salesforce: {str(e)}"
@@ -213,7 +214,7 @@ def generate_dpr(files):
213
  # Update the DPR record with the PDF URL
214
  if pdf_url:
215
  sf.Daily_Progress_Reports__c.update(dpr_record_id, {
216
- 'PDF_URL__c': pdf_url
217
  })
218
  salesforce_result += f"Updated PDF URL for record ID {dpr_record_id}\n"
219
 
@@ -267,4 +268,3 @@ iface = gr.Interface(
267
 
268
  if __name__ == "__main__":
269
  iface.launch()
270
-
 
137
  )
138
  content_document_id = content_document['records'][0]['ContentDocumentId']
139
 
140
+ # Generate a valid Salesforce URL for the ContentDocument
141
  content_document_url = f"https://{sf_connection.sf_instance}.salesforce.com/{content_document_id}"
142
+
143
+ # Ensure the link is valid
144
  return content_document_id, content_document_url, f"File {filename} uploaded successfully"
145
  except Exception as e:
146
  return None, None, f"Error uploading {filename} to Salesforce: {str(e)}"
 
214
  # Update the DPR record with the PDF URL
215
  if pdf_url:
216
  sf.Daily_Progress_Reports__c.update(dpr_record_id, {
217
+ 'PDF_URL__c': pdf_url # Storing the PDF URL correctly
218
  })
219
  salesforce_result += f"Updated PDF URL for record ID {dpr_record_id}\n"
220
 
 
268
 
269
  if __name__ == "__main__":
270
  iface.launch()