Get Documents and Attachments out of Salesforce

February 8, 2010 · Filed Under Configuration, Spring 10, Tips and Tricks, salesforce.com · 3 Comments 

As Content will be included in all Salesforce licenses (for completeness, I'll add 'to some degree') with the Spring '10 release, orgs will be faced with the daunting prospect of getting their documents and attachments out of Salesforce and into Content.

I had this problem when Content was first released and I was asked to be one of the first SysAds to use it. At the time, we used Solution 1 (below), but since then, other products have been released to help with this.

Why is it even an issue?

  • Surely we can download each file? Yes, but who wants to?
  • Can't we do a Data Export and then upload those to Content? Yes, but all the files are renamed with their 15-character Ids, making renaming them all-but-impossible.

salesforce.com and DreamFactory to the rescue!

Solution 1

Summary: Use a script to rename all exported files. A (wonderful!) salesforce.com employee, Nick Marcantonio, wrote a Perl script to perform the transformation. Here it is, in all its glory:
# Nick Marcantonio
# nmarcantonio at salesforce.com
# 08/07

$file = 'Attachment.csv';

open (F, $file) || die ("Could not open $file!");

$line = <F>; #read first line which is nothing but column headers
while ($line = <F>)
{
  ($id,$name) = split ',', $line;
  chomp($id);
  $id =~ s/\"//g;
  chomp($name);
  $name =~ s/\"//g;
  
  #print "$id : $name\n";
  
  $result = rename($id, $name);
  #print "$result\n";
}

close (F);
The instructions:
If you've done a data export you've noticed that all attachments are placed in the Attachments subfolder and named with their salesforce ID, not the actual file name or extension. One must then consult the Attachment.csv file included in the data export to find the name associated with the ID and rename the file. Attached to this solution is a Perl script that will rename all of the exported attachments to their proper names. Please follow these steps to run this:

1. Perform a data export and unzip the resulting zip file
2. Launch the data loader and export from the Attachments table ONLY the Id and Name column. This file must be named Attachment.csv.
3. Install ActivePerl. This will allow perl scripts to be run on a Windows machine. ActivePerl is available here (http://www.activestate.com/activeperl).
4. Copy the Attachment.csv file and the attached AttachmentParser.pl file to the Attachments subdirectory of the data export.
5. Double-click on AttachmentParser.pl.

All of the files named with their salesforce IDs will be renamed with their proper names and file extensions.

(This solution will work for documents as well. Follow the same procedure and be sure to name the extract from the Documents table Attachment.csv) 

Note: This will not preserve folders, as far as I know. You may be able to recreate this by exporting the Folder table and doing some work on that, as the Document table does include a FolderId column.

A heartfelt thank-you to Nick Marcantonio for his help!

Solution 2

Install DreamFactory's FREE DreamTeam Document Management application from the AppExchange to drag-and-drop your Documents to your desktop.
This doesn't work with Attachments, though, so you may need to use another method for them.

Please let us know how it goes - good luck and enjoy Content!

New Developer Library Released

Today, Developer Force (http://developer.force.com) released its new library. Here are a few of them. All can be found at http://wiki.developerforce.com/index.php/Documentation.

Workbook
http://www.salesforce.com/us/developer/docs/workbook/index.htm

Fundamentals
http://www.salesforce.com/us/developer/docs/fundamentals/index.htm

Cookbook
http://www.salesforce.com/us/developer/docs/cookbook/index.htm

Apex Advanced Code Example
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_shopping_cart_example.htm
https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N30000001saDCEAY

And many more to come!

Proof that salesforce.com listens – and comprehends

September 29, 2009 · Filed Under salesforce.com · 4 Comments 

About two weeks ago, I posted a list of the many setup steps I took to make my Winter ‘10 prerelease org useable. Those are the same steps I have to take whenever setting up any Developer Edition org for the first time as well.
An insider at salesforce.com forwarded me this email that a senior person sent to quite a few also-senior people on various product teams:

Subject:
Preparing a New Org. Each Pre-Release. In 27 steps.
Body:
Yikes. http://www.x2od.com/2009/09/16/preparing-a-new-org.html

This is not the most widely-read blog about Salesforce, but it feels good to know that salesforce.com does have its ear to the ground and is taking seriously even the indirect feedback that we bloggers provide.

Kudos, salesforce.com.

PS. While I’m at it, I may as well also mention that too many fields are invisible to every profile. Example on Account: Site, Ownership, SIC Code, and more. And Annual Revenue is invisible to Customer Portal users. It would be great to have a guide or documentation.
PPS. Turns out that there’s no rhyme nor reason why some orgs have various fields invisible. Between demo, developer, trial, prerelease, and more, some fields are available and some are not. It is a huge waste of time to find all the fields and enable them.

Dashboards are Improved AND New in Summer 09

The Summer09 prerelease orgs are here, so get yours now! Upon first look, something cool stood out and merits immediate posting:

Dashboards are improved. The colors are more vivid, there’s detail in the bars and pie chart wedges, and… pie charts can now display the actual and percentage values!

Dashboards are also new. Visualforce pages can now be included as dashboard components, and there’s a new “Color-Blind Palette on Charts” setting for each user. Here are before and after shots.

Dashboard with regular color scheme

Salesforce dashboard with regular color scheme

Salesforce dashboard with color-blind/alternate color scheme

Dashboard with color-blind/alternate color scheme

The Ultimate Visualforce Events Tab – Almost

January 5, 2009 · Filed Under Configuration, Visualforce, Winter 09, salesforce.com · 4 Comments 
Check old blog posts, and you’ll see that I’ve been working on custom Events and Task tabs for a while now. A Task Visualforce tab (that mimics the Task box on the Home Page) is almost ready to come out, but the Events Enhanced List tab is (pretty much) here!

This bears emphasizing: Enhanced Lists were initially not fully released for Activity/Event/Task objects, but are available now.

The code is ridiculously simple, thanks to the apex:EnhancedList Visualforce tag:

<apex:page standardController="Task" >
<apex:enhancedList type="Activity" height="800" rowsPerPage="50" />
</apex:page>
See? Nothing to it! Or so we thought. There are some catches (there always are):

  1. The original use-case required displaying all upcoming events without the header or sidebar. We still cannot do this. Quoting from the Winter ‘09 Release Notes: The enhancedList component is not allowed on pages that have the attribute showHeader set to false.
  2. We’d like to create a custom tab for this page. We create a Visualforce Tab, pick a custom icon, and show the page… and when I click on the tab, the enhanced list is displayed, but the tab is not highlighted. Also, the custom icon I chose is not displayed. How do we highlight our tab?
    After making the page, we make the tab as desribed above. Then we RETURN to the page and add a tabstyle modifier to the apex:page tag, like so:
    <apex:page standardController="Task" tabstyle="enhanced_activities__tab">
    <apex:enhancedList type="Activity" height="800" rowsPerPage="50" />
    </apex:page>
    
    [Of course, change the tab name to whatever you choose.]

    Success? Not quite. There’s another catch:

  3. The tab is highlighted (brown in our case), but the color and icon for the enhanced list are standard green/home.
    Sadly, I have no workaround for this one. Sorry.
To repeat: Enhanced lists were not initially fully available for Events and Tasks, but now do support them.

Moving forward, consider if you want to create a particular enhanced list view instead of calling the standard enhanced Activity list as I have done here. If you would prefer to make a custom enhanced list view, then you will need to add more code, but that is beyond the scope of this post.

Enjoy!

Next Page »