0

I recently developed a script that could integrate with Salesforce and move documents via file blobs to individual Salesforce folders but with our organizations recent migration to Salesforce Lightning, I'm not able to find the Folder IDs that are needed to point captured files towards. My current code snippet is as follows:

spo_file=test.txt
Document doc = new Document(Name=spo_file, Body=res.getBodyAsBlob(), FolderId=folder_id);
insert doc;
Blob headerValue= blob.valueOf(res.getBody());
String body = EncodingUtil.base64Encode(headerValue);

The problem I have here is that the original Folder IDs for document folders are no longer appearing in the new Salesforce Lightning folders since they now use Case Safe IDs and I haven't been able to find a workaround that gives me Folder IDs that I can use in my Apex code. Any ideas on where I should begin?

Here is a below error message I sometimes get from Apex due to the Case Safe Folder ID:

Salesforce Apex periodic code failure

  • Do you have a custom folder Object? a0q is a custom object id – Pranay Jaiswal Jun 19 '19 at 14:55
  • No. When I created the Document Folder for a TestFolder, this is what it gave me as the 'Document Folder Id CASESAFE' value – murkywaters Jun 19 '19 at 14:56
  • DOcument Folder starts with 00l, – Pranay Jaiswal Jun 19 '19 at 14:58
  • How do I get that in Lightning? – murkywaters Jun 19 '19 at 15:00
  • Create custom UI, and use this SOQL to get all document folders, SELECT Id,CreatedDate,DeveloperName,Type FROM Folder WHERE TYpe ='Document' – Pranay Jaiswal Jun 19 '19 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.