Friday, June 12, 2015

SQLForce Gave Me Time to Ride My Motorcycle.

This morning I was asked to change the "Type" of around 400 Salesforce Campaigns from one type to another.  The type was simply wrong.

No sweat. The following short Python did the job with just a few minutes work on my part, saving my next few hours for a bit of motorcycle riding.

import SQLForce

if __name__ == '__main__':
    session = SQLForce.Session("production")
    updateRecs = []
    campaignSOQL = "SELECT id, owner.alias FROM Campaign WHERE owner.alias='mnakano' AND type='Event-Tradeshow/Conference'"
    for rec in session.selectRecords( campaignSOQL ):
        updateRecs.append( [, 'Training'])
    if len(updateRecs) > 0:
        print("Updating " + str(len(updateRecs)) + " campaign records")
        session.update("Campaign", ["Type"], updateRecs)
        print("No records to update")

I will never understand why so many people put up with DataLoader to do mass updates. Python with SQLForce is free and is so much faster.

You can get the SQLForce Python module for free at

No comments: