I know I rave about the Salesforce community. A lot. And for very good reason. A few weeks ago, I was asked if you could send shortened URLs from Salesforce. Sending them wasn’t the problem – there’s dozens of approaches there. But I didn’t quite have a solution for generating those links. I knew my team could figure it out quickly, but it was after-hours when the question came in and I wanted an answer fast. I turned to Twitter, and within a few minutes, I had several approaches lined up and could definitively say it was possible. The next morning, I awoke to an incredible blog post by Doug Ayers, who took my question as a challenge and stayed up late writing the code.
In short, his solution is brilliantly simple. First, you sign up for a free bit.ly account. In Salesforce, create a “Named Credential” (a tool designed for storing login credentials and endpoint URLs for integrations; Setup -> Security Controls -> Named Credential), then a Custom Field to hold your shortened URL. Next, copy and paste his Apex code – yeah, it’s ready to fly and very well-commented. Finally, use the Process Builder to create a Process, activate it, and test it out. Due to some known limitations with the Process Builder (if you need to do this in bulk, you could hit some problems), my team needed to swap that out for a Trigger, and a few other modifications were needed to make it fit into the process flow, but the hardest part was solved with just one tweet and the incredible #askforce community! Check out Doug’s post here, and enjoy this awesome solution!
-Jared and the Salesforce Guys
Cover image by Joelle Diane
Dreamforce Sock Update:
The socks are done! They look awesome, and feel even more incredible! I think I’ll be knitting another pair of Dreamforce socks next year, and I definitely plan on strolling around the convention in these!