Scenario or Situation
While addressing a requirement for a packaging solutions client in Atlanta, Georgia, there was a need to enable Salesforce users to upload documents from Salesforce entities.
To overcome Salesforce’s storage limitations, uploaded documents are stored in SharePoint.
Challenge or Obstacle
We’ve successfully implemented file upload functionality from Salesforce to SharePoint by developing a custom Lightning web component. We relied on SharePoint REST APIs for direct uploading from Salesforce to SharePoint.
Yet, we encountered an issue while attempting to upload files containing special characters, which led to an error.
Resolution or Solution
var updatedFileName = encodeURIComponent(this.files.name); var url1 = 'https://br.sharepoint.com/sites/SFUpload' + "/_api/web/GetFolderByServerRelativePath('/Sites//SFUpload/Document Library')/Files/AddUsingPath(overwrite=true,decodedurl='" + updatedFileName + "')";
Conclusion or Summary
By encoding the file name, we have successfully managed to upload a file with special characters from Salesforce to SharePoint.