Skip to content

Using Perl to Import Products into Salesforce.com Opportunities

December 24, 2009

Believe it or not I am in sales… Didn’t start out like that, but as some techies would say sold my soul the devil 🙂
Anyway one task that I get to do too often these days is creating, and approving Salesforce.com opportunities from my customers. They usually send me an Excel file with their proposed purchase order, I need to upload it to Salesforce.com so I can get the discounts approved.

Adding every single part number by hand is tedious, boring work, especially at the end of the quarter when the pressure to “make the numbers” builds up and we have no time to waste. So I revived some of my old Perl memories and wrote a little script that imports all the products at once into an already created opportunity.

If this is useful to you just follow these steps:

  1. Create Salesforce.com opportunity, and save it
  2. Copy the last part of the URL (that is your opportunity ID).
    Example: https://na6.salesforce.com/0068000000K32EA the ID is 0068000000K32EA
  3. Run import-products with your product file, Salesforce.com credentials and opportunity ID

You are set!

The product file is just an Excel with 2 columns, the first being the SKU or part number, and the second the desired quantity. Save the file in CSV format (you can do this by selecting CSV as the save type in Excel). Now use this file to import your products.

Script usage:

import-products --csv=product.csv  --opportunity=OpportunityID
                    --user=UserName --pass=Password
                    [--delete]

        product-file.csv
            MUST be a Comma Separated file with two columns (SKU, Quantity).
            No header line.

        opportunityID
            MUST be an existant Salesforce Opportunity to which you want to add
            the products from the product.csv to.

        user, pass
            Salesforce.com user name and password.

        delete
            Delete all of the opportunity's products before adding any new ones.

 

Requirements:

  • Perl 5.8 or higher

CPAN modules

  • WWW::Salesforce::Simple
  • Getopt::Long;
  • Text::CSV_XS;
  • Scalar::Util

You can get the source code from here. Hope you can use it and that it saves you some time as well!

Advertisements

From → Perl

One Comment
  1. Francois Labelle permalink

    Could you post the Perl script again? The link does not seem to work.
    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: