The Silver Lining

Lessons & Learnings from a salesforce certified technical architect.

Archive for October 2011

Salesforce: Stop email being sent on user creation or password reset or …

leave a comment »

I’ve had to do this a few times but infrequently enough for me to forget how to do it each time. Forgetting things isn’t usually an issue because of our Google Overlords and their mighty The Google but it’s quite a journey down the rabbit hole to find this specific information.

The reasons it’s tricky to find is because the setting that controls whether an email is sent to the user on creation is not directly associated with users but with DML. Long story short you need to set a particular Database.DMLOption e.g.


User u = new User();
// Add some details here ...

// Set the DML options
Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerUserEmail = false;

Database.insert(u,dlo);

Hopefully this information will now be easier to find next time I forget 🙂

Written by Wes

October 30, 2011 at 1:12 pm

Posted in Apex, SalesForce

Tagged with , , , , ,

A gem to help you document your Rails ActiveRecord model

with 2 comments

I’ve been using the “annotate” gem for a while and it’s simple whilst incredibly useful. Essentially once run it documents each resource in your database within the appropriate file. Here’s how to get it working.

Step 1

Install the gem. There are a few ways to do this but I usually include the following line in my Gemfile:

gem 'annotate'

Then run “bundle install” from the command line.

Step 2

Generate the schema annotations by running:


annotate

in the root of your rails project directory and it will inject the schema details for each “table” into the respective “model.rb” file e.g. “user.rb” might contain:

# == Schema Information
#
# Table name: users
#
#  id          :integer         not null, primary key
#  screen_name :string(255)
#  name        :string(255)
#  created_at  :datetime
#  updated_at  :datetime
#

Written by Wes

October 21, 2011 at 5:50 pm

Knowledge Tree for Salesforce User Roles

with 3 comments

UX that makes you say things like, "Gee Whizz" and "Cowabunga"

Many moons ago @ratherGeeky was searching for an AppExchange app that would neatly display user roles so that she could be the best admin she could be. I had a poke around and there were a few nice apps out there but nothing with a simple, neat display of user roles.

Since then CloudSpokes was created, and a competition to that effect was released using the concept and tools that I was going to use (@jeffdonthemic smells like turnips btw). The outcome of the competition was a few very cool apps, but nothing that was package-ready so I pressed ahead anyway.

I’m happy to announce that you can now get Knowledge Tree for Roles on the AppExchange for free. It’s definitely a point solution, very specific in the problem it’s trying to solve but I think it does that well. I have a roadmap for the product and will [ever so slowly] be releasing new features e.g. drag and drop will be killer.

If you install the app and like it then please, please, please (please (please)) review it as it helps exposure and will hopefully lead to me getting more time to work on it. If you don’t like it let me know why via email (wes@cloud-corporation.com) and I’ll do my best to turn your frown upside down.

Written by Wes

October 14, 2011 at 11:23 am

Across the Pond with Shannon Hale

leave a comment »

Shannon is Senior Product Manager for Declarative Apps at Salesforce.com

@abhinavguptas and I were curious as to the identity of the creator of the SetupScripter, which is now incorporated into the salesforce.com Org setup menu. I dug around a bit and managed to uncover her real identity – community please meet Shannon Hale, Shannon Hale this is the community. She didn’t just stop with that wonderful piece of UX but has moved onto bigger and better things, but I’ll let her tell you about those.

If you’d like to learn more about the genius that is Shannon or just have a chat with her you can get her on twitter at @shannonsans or @bathtubdreamer. You can also check out her online presence at shannonsansserif.com and bathtubdreamer.com.

Onto the Q&A!

Who is Shannon Hale? How did you get into software development and UX design?

I started out as a writer, but in a different field — I wrote and edited for some independent Canadian music and culture magazines. I started technical writing to help pay the bills, and from there wandered through a series of tech positions: technical training, systems analysis and design, and software development. In 2001 I became obsessed with why a product I was coding was difficult to use, and began to independently study interaction design and user experience.

When I’m not being a complete geek — which I am even at home, I always have personal and volunteer web projects going on — I’m sewing, knitting, or binding books. I’m one of those people who always needs to be doing something with their hands.

Read the rest of this entry »

Written by Wes

October 14, 2011 at 10:49 am

“Dropping” a mongohq database on Heroku

leave a comment »

I’ve used inverted commas around the word ‘dropping’ because it doesn’t look like you can drop a mongohq database – what you can do however is drop all the collections in the database. I was doing this through the add-on interface in heroku but that got tired quickly, and after some googling it looked like the solution was to write a custom rake task and drop it into lib/tasks/; the file can be named anything with a ‘.rb’ extension. The code follows:

namespace :mdb do
    desc 'Drops all the collections for the database for the current Rails.env'
    task :drop => :environment do
      if ENV['MONGOHQ_URL']
        uri = URI.parse(ENV['MONGOHQ_URL'])
        conn = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
        DB = conn.db(uri.path.gsub(/^\//, ''))
        DB.collections.each do |collection|
          begin
            collection.drop
          rescue
            puts "Can't drop: " + collection.name
          end
        end

      end
    end
end

Note that the exception handler isn’t perfect and essentially all I’m doing is skipping the system collections that can’t be dropped.
Once you’ve deployed this code to the heroku servers it’s simple to execute:

heroku rake mdb:drop

Written by Wes

October 2, 2011 at 5:05 pm

Posted in Ruby

Tagged with , , , , ,

%d bloggers like this: