function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mohan SelvamMohan Selvam 

Is it poosible to archive records? we have reached 64% in Data Storage.

Hi all,
we have reached 64% in Data Storage, Is there any possibilities to Archive records?
There are 2 possibilities to solve this problem.
One way is to puchase additional sapce from salesforce
and anothere one is to backup our records and delete them.
Please tell me is there any other methods avalibale to resolve this issue.
Please send me the link.
Thanks and Regards 
S Mohan
Best Answer chosen by Mohan Selvam
Chidambar ReddyChidambar Reddy
Hi Mohan, giving you an example is almost building it

I will tell you the process

Find out which object records are taking more data storage

Data Management > Storage Usage

Create a visualforce page to select the date fields (startDate and endDate) or you can even use two custom labels to specify them


Create two batch classes where one is to convert them as attchments and store it under their parent, lets say you have specified two dates
and you have large number of contacts
then the batch should iterate over Accounts (you can have a field which specifies whether it is already archived or not)

in execute method, query all contacts within the specified time

create a csv file 
create a string that stores the body of the file
and give header column, values seperated by commas
string body = 'Column1,Column2,Column3'+'\n';

then iterate through data
for(i){
body+='valueiForColumn1,valueifroColumn2,valueiforcolumn3'+'\n';
}

convert this string as blob at the finish 
and set the blob value as body of the attchment
add all attachments and insert them out side of the loop and then update Accounts that they are already processed


Another batch is to delete all the records within the specified region, by iterating over already processed records

Thanks

All Answers

Iqrar AhmedIqrar Ahmed
Hi Mohan,
I would prefare you to backup data with cloud Backup service Providers like "CloudAlly" because salesforce also prefare these activites in situations you are suffering from.Here is link for backup service.
http://www.cloudally.com/salesforce-backup/

Regards
IQRAR AHMED
Senior Salesforce/.Net Developer
Chidambar ReddyChidambar Reddy
Hi Mohan,

There is an additional option that converting data storage into file storage (csv) using apex and adding them as attachments under their parent objects, you can achieve this by using apex & visualforce

64% is not an urgent thing, so you may also look at some other cheaper data storage providers and integrate them to salesforce

Thanks
Mohan SelvamMohan Selvam
Hi IQRAR AHMED

Thanks for you immediate response.

Regards 
S Mohan
Mohan SelvamMohan Selvam
Hi Chidambar Reddy 

Thank you so much for your response

Regards
S Mohan
Mohan SelvamMohan Selvam

Hi Chidambar Reddy

If you don't mind could you please share the sample code to convert Data Storage into File storage
Chidambar ReddyChidambar Reddy
Hi Mohan, giving you an example is almost building it

I will tell you the process

Find out which object records are taking more data storage

Data Management > Storage Usage

Create a visualforce page to select the date fields (startDate and endDate) or you can even use two custom labels to specify them


Create two batch classes where one is to convert them as attchments and store it under their parent, lets say you have specified two dates
and you have large number of contacts
then the batch should iterate over Accounts (you can have a field which specifies whether it is already archived or not)

in execute method, query all contacts within the specified time

create a csv file 
create a string that stores the body of the file
and give header column, values seperated by commas
string body = 'Column1,Column2,Column3'+'\n';

then iterate through data
for(i){
body+='valueiForColumn1,valueifroColumn2,valueiforcolumn3'+'\n';
}

convert this string as blob at the finish 
and set the blob value as body of the attchment
add all attachments and insert them out side of the loop and then update Accounts that they are already processed


Another batch is to delete all the records within the specified region, by iterating over already processed records

Thanks
This was selected as the best answer
Mohan SelvamMohan Selvam
Hi Chidambar Reddy

Thanks for you time and valuable guidance.

Regards 
S Mohan
Vaishali Shrivastava 18Vaishali Shrivastava 18
Hi Mohan,

Just wanted to check if you got the archiving done as required with the solution suggested in the trail. Also, can you provide me the sample code, if it is readily available to you?

Thanks,
Vaishali