Deprecated: Assigning the return value of new by reference is deprecated in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 248

Strict Standards: Non-static method GoogleSitemapGenerator::Enable() should not be called statically in /home/warped/public_html/sfdc-heretic/wp-content/plugins/sitemap.php on line 2452
Salesforce Heretic » Salesforce.com Mail Merge, Part II: “Word made me do it…”

April 18, 2006

Salesforce.com Mail Merge, Part II: “Word made me do it…”

Filed under: Salesforce.com, Mail Merge — heretic @ 12:48 pm

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 260

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 261

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 262

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 263

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-includes/functions-formatting.php on line 76

This post best read with Twisted Sister, We’re Not Gonna Take It playing in the background…

Back in our introduction to this series, I elaborated on some of the issues surronding Mail Merges in Salesforce.com. In this part we’re going to look at how Word handles a Mail Merge, and figure out how we’ll get our data ready to be merged.

Before I get started, there are a ton of howto’s, walkthroughs, examples, and whatnot that can be Googled for a basic introduciton on doing a Mail Merge in Word. This isn’t going to be an in-depth discussion on what buttons to click in which order. I’m going to be working more in the abstract in this part.

So lets set up a few premises that we’ll be using as we go forward in our series. We’re going to define two use cases, one which we’ll use at the end of the series to actually do a fully working mail merge, the other will showcase an inherit limitation.

Our first case is your typical lead letter. The kind of letter where you introduce yourself and/or your company and products/services. Typically this is a very standard kind of merge, salutation, name, addess, user name, and user title are about as far as we’ll need to go in this letter. The second use case is a quotation for an opportunity. Several opportunity fields (from the opportunity / account) and selected contact are merged in along with the opportunity line items.

Lets presume for a minute our 2 letters are complete, and that they’re in use now in Salesforce.com. You’ve created the merge fields and the document body. Lets ask this question: If this were a regular MS Word Mail Merge where whould we get our data?

Typically the data for a Word Mail merge is most commonly from MS Excel, Access, or some other database. Lets look at an Excel merge example. You’ve got a spreadsheet with names and addresses and you want to make labels. In Excel (your data source) each “document” (label in our case) is on a seperate row. There’s no capability for you to merge a record on one row with some related data on another page in the spreadsheet. Word is kinda dumb when it comes to relational databases, it’s got a “one row” complex. What does this mean to us?

Opportunity Line items: If you model the data in a Word-centric view you have all the opportunity fields, account fields, select contact fields, user fields (user name, user title, etc.) on a single row. But the opportunity line items are multiple distinct records — unbounded data. you have some n rows of line items to deal with. How do you merge them? If you put them starting on the next row of the same Excel spreadsheet your product name might line up under the account name column. Your merged document would look, well, funky. But if you put the line items on aother page of the spreadsheet, how do you tell Word to go there to get it, and only get the correct ones? As far as I’ve looked, you can’t.

So given this, we know the easiest way to do a Mail Marge in Word is to use a simple, flat, “database” record to store our data in. The simplest one: CSV files. Comma Seperated Values. But how do we get the data from SFDC to popultate it?

In Part III we’ll look at how Salesforce.com provides a nice (yet totally unsupported, of course) shortcut for us to get the data and field names for a given merge. We’ll also start looking at some real code to handle it.

License

This work is published under a Creative Commons Attribution-ShareAlike 2.5 License.


Strict Standards: Only variables should be assigned by reference in /home/warped/public_html/sfdc-heretic/wp-includes/functions.php on line 590
« Mail Merge - The Third Rail of Salesforce.com  
Strict Standards: Only variables should be assigned by reference in /home/warped/public_html/sfdc-heretic/wp-includes/functions.php on line 590
Salesforce.com Mail Merge, Part III: “Spaulding, this calls for the ole Billy Barule…” »

2 Comments


  1. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 260

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 261

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 262

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 263

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-includes/functions-formatting.php on line 76

    Just a quick comment to those reading Part II - Chris Hopkins over at SFDC posted this comment regarding the current state of Mail Marge.

    I’m quite interested to see the plugin architecture and to see if it’s done in a browser-agnostic way. Regardless I may hold back Part III (already written) as parts of it may be changing with the update on Friday.

    Comment by
    Deprecated: Function ereg() is deprecated in /home/warped/public_html/sfdc-heretic/wp-content/plugins/google-analyticator.php on line 272
    heretic — April 18, 2006 @ 12:52 pm


  2. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 260

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 261

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 262

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-content/plugins/codesnippet/codesnippet.php on line 263

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/warped/public_html/sfdc-heretic/wp-includes/functions-formatting.php on line 76

    Sadly, the new merge is still activex based so IE/windows only.

    That said it still covers 90 percent of our users…

    Anyway, the new bits allow you to:

    Override the entire merge process (you get all the ids etc)

    Use your own com object to either modify/intercept the data source before the merge but still use the standard merge template generation component

    Use your own com object to generate the final doc (you get the path to the data and path to the template)

    Lastly the code is much easier to script. You can also specify to auto save the results, which are now stored in a folder off the desktop (sub folder name can also be controlled)

    I’m planning on a component that will combine the current search and replace code (which is slow and can be hard to format) with native word merge functionality. The trick is to correctly modify the data source and the template to support dynamic, nested datasets (line items for example). I know what to do but finding the time is always a struggle.

    If anyone is interested, I have an open source c# build of the system that is a good starting point for writing your own merge components
    Out of the box it generates a merge data source from the api (which can be tricky) and has a ui to do a bulk merge/manage bulk merge results (works offline as well)
    It’s not an official salesforce product though, so there is no support

    Comment by
    Deprecated: Function ereg() is deprecated in /home/warped/public_html/sfdc-heretic/wp-content/plugins/google-analyticator.php on line 272
    Chris Hopkins — April 19, 2006 @ 1:33 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.