@Alex : Programmatically The best way to get the actual attachment data out of Salesforce is to query the Attachment object for the Attachment Ids and then use the retrieve() API call to get the Body data. I have done this before for integrations and it is very fast.
You can try this code :
select Id, Custom_Field__c,
(SELECT Id, Name FROM Attachments),
(SELECT Id, Title FROM Notes)
from Custom_ObjectAPIName__c
@Ishwar Shinde How can I change the name and the type of attachment? It is hard for me to guess which software should I use for opening the file, since some of them are pdf or jpg. And I also the a name for identifying which record belongs to. Thank you.
@Ishwar Shinde It works well. But I want to ask one more question. How can I solve the problem of repeating file name? It seems that the file with repaeting name cannot be fixed by this approach. Is there any method to change the name inside the database before exporting it out? Thanks.
Here are few options which I can think of- 1. Write the apex code/batch which will check the duplicate attachment name and rename it uniquely. Or 2. Export the attachmnet Id and Name using data loader. Find duplicates in excel, rename it and then again update the name in salesforce using data loader. Or 3. Add validation on Name field to make it unique by code.It will avoid creation of attachmnet with duplicate names. Or 4. In excel which you have exported, check for duplicate names and make it uniquie locally before renaming file name.
@Ishwar Shinde Thanks for your help! Here is my situation now: My custom object is actually a form for public to fill in their information. In the form, there are 3 question for them to upload the attachment. One of the question can allow them to insert 1-3 attachment(s), and the other two question can only insert 1 attachment. Is there any way to rename the attachment, so that I can know that which attachment belongs to which question? Actually, it is not a must. The backup plan is to just simply ask the uploader to rename according to format before they upload. Really appreciate you work! Thank you.
@Ishwar Shinde Sorry, I am really quite new to Salesforce. I want to ask that after writing a trigger, where can I call it? And since attachment only have one field in a record of custom object, how can I identify them in a trigger? I can identify them in my aoex code since I use variable in there. Can this variable also use in triggers? Also, can triggers just add the name of record in front the attachment? Example: There should be 3 type of attachment, A, B and C. For example, team A submit the form. I want the attachments to be TeamA_A. Can triggers perform this? Thanks for your help!
Hi Alex, You can try this tool : https://sforce.co/34thF8U where you can download almost any Attachment or File under one or multiple records all at once and also support download of Static Resource and Documents too.
You can use "Data Export" functionality of salesforce to get object data allong with attachmnets.
Please refre below link for more details -
https://www.shellblack.com/administration/data-export/
Hope it is helpful.
Thanks,
Ishwar Shinde
All Answers
Programmatically
The best way to get the actual attachment data out of Salesforce is to query the Attachment object for the Attachment Ids and then use the retrieve() API call to get the Body data. I have done this before for integrations and it is very fast.
You can try this code :
Using Data Loader :
Check this article . It contains step by step procedure to export attachments .
http://dataloader.io/dealing-attachments
You can use "Data Export" functionality of salesforce to get object data allong with attachmnets.
Please refre below link for more details -
https://www.shellblack.com/administration/data-export/
Hope it is helpful.
Thanks,
Ishwar Shinde
It is hard for me to guess which software should I use for opening the file, since some of them are pdf or jpg. And I also the a name for identifying which record belongs to. Thank you.
Please try below steps to rename the attachments -
https://help.salesforce.com/apex/HTViewSolution?id=000007269&language=en_US
Hope it will help.
Thanks,
Ishwar Shinde
Here are few options which I can think of-
1. Write the apex code/batch which will check the duplicate attachment name and rename it uniquely.
Or
2. Export the attachmnet Id and Name using data loader. Find duplicates in excel, rename it and then again update the name in salesforce using data loader.
Or
3. Add validation on Name field to make it unique by code.It will avoid creation of attachmnet with duplicate names.
Or
4. In excel which you have exported, check for duplicate names and make it uniquie locally before renaming file name.
Hope anything from above will work for you.
Really appreciate you work! Thank you.
On insert of attachment, you can write trigger and rename the attachment (considering you know how and what name you need to specify for attachment).
Please mark this as best ans if this helps!!
Example:
There should be 3 type of attachment, A, B and C. For example, team A submit the form. I want the attachments to be TeamA_A.
Can triggers perform this? Thanks for your help!
https://www.sfdcfileexporter.com/sffxhome
You can try this tool : https://sforce.co/34thF8U
where you can download almost any Attachment or File under one or multiple records all at once and also support download of Static Resource and Documents too.
Thank,
Sonam
- Attach file related to any Salesforce object on Amazon S3.
- Move existing Salesforce files and attachments in Amazon S3
- Multiple file uplaod.
- No file size limit for upload.
- File access control capabiliy.
- Track file downloads by users.
- File exlorer capability.
https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000CW1OXEA1Here is our email address. Let us know if you have any query.
support@neiloncloud.com
Thanks.
Hi Alex,
If you are looking for an automated method, you can try out the Skyvia data integration online tool.
Just connect with your Salesforce account >> create an export package >> add new task >> choose "Attachment" in the "object" list
Find more details in their tutorial: https://skyvia.com/tutorials/how-to-export-data-from-salesforce