Encrypting and Decrypting on Salesforce and Node.js

Need to send secure messages back and forth between Salesforce and Node.js?  Whether it’s Heroku, AWS, or somewhere else, Node.js is an important platform to be able to communicate securely with Salesforce on.

Salesforce provides a fairly robust Crypto class.  I like the AES256 with Managed initialization vector (aka IV) that Salesforce provides.  The IV is 16 bytes of random/pseudorandom data that salts the encryption so the output is different every time even if the input is the same.  This prevents hackers from being able to spot patterns in the encrypted data, and makes it very difficult to brute force.  The IV gets prepended to the encrypted message so it is available on the other end when decrypting.

In Salesforce, Crypto.encryptWithManagedIV() and Crypto.decryptWithManagedIV() handle creating the IV, and prepending and parsing of the IV.

It’s pretty simple to build encryption and decryption using these methods on the Salesforce platform, see the example here.

But when it comes times to send and receive these encrypted messages on another platform, Node.js in this case, it becomes more difficult.  Managing the IV must be handled differently.  I found an article on how to do this with Java and a partial answer for Node.js.  But I couldn’t seem to find a complete, working example for Salesforce <-> Node.js.  So after I figured out how to make this work on my own, I thought I should blog about it to save others the trouble!

 

Saleforce

Here is example code of encrypt and decrypt, with some values from Node.js also included to be decrypted on Saleforce.

public class Encrypt {

    private static final Blob KEY = EncodingUtil.base64Decode('LHDK5bekAHJOFfXXzkd5uR/AoLBNPDNLIMAK8M0xss8=');    

/*

//execute anonymous example:

String secret = 'Shhhh..  This is a secret.';
System.debug('1: ' + secret);

String encrypted = Encrypt.encryptString(secret);
System.debug('2: ' + encrypted);

String encryptedAgain = Encrypt.encryptString(secret);
System.debug('3: ' + encryptedAgain);

System.debug('4: ' + Encrypt.decryptString(encrypted));
System.debug('5: ' + Encrypt.decryptString(encryptedAgain));

String encryptedfromNodeJS = 'cLaipdqsdGM/z+e+QjpqjUKeeQR26XSJdpUvgNE1areZHhB8DeAA+9xOgZO+wEe9';
System.debug('6: ' + encryptedfromNodeJS);

String encryptedfromNodeJSagain = '1NfNnjF5ROu3W9O8G14yzpjbpLDlEYjOjg/v1or5f7OgNZj+p/v3gdj5+NCR6olD';
System.debug('7: ' + encryptedfromNodeJSagain);

System.debug('8: ' + Encrypt.decryptString(encryptedfromNodeJS));
System.debug('9: ' + Encrypt.decryptString(encryptedfromNodeJSagain));

*/
    
    public static String encryptString(String clearText) {
        String encryptedText = null;
        Blob encryptedBlob = Crypto.encryptWithManagedIV('AES256', KEY, Blob.valueOf(clearText));
        encryptedText = EncodingUtil.base64Encode(encryptedBlob); 
        return encryptedText;
    }
    
    public static String decryptString(String encryptedText) {
        String clearText = null;
        Blob encryptedBlob = EncodingUtil.base64Decode(encryptedText);
        Blob decryptedBlob = Crypto.decryptWithManagedIV('AES256', KEY, encryptedBlob);
        clearText = decryptedBlob.toString();
        return clearText;
    }            
    
}

 

We can run this code in execute anonymous and we can see that we encrypt the same value twice, get two different encrypted values which decrypt to the same value.  We also decrypt two different encrypted values which came from Node.js and they decrypt to the same value.

 

Node.js

Here is example code of encrypt and decrypt, with some values from Salesforce also included to be decrypted on Node.js.

var KEY = Buffer.from('LHDK5bekAHJOFfXXzkd5uR/AoLBNPDNLIMAK8M0xss8=', 'base64');
const crypto = require('crypto');

var secret = 'Shhhh..  This is a secret.';
console.log('1: ' + secret);

var encrypted = encryptString(secret);
console.log('2: ' + encrypted);

var encryptedAgain = encryptString(secret);
console.log('3: ' + encryptedAgain);

console.log('4: ' + decryptString(encrypted));
console.log('5: ' + decryptString(encryptedAgain));

var encryptedfromSFDC = 'eFSWOcUjUiXKcfM+szX9HnjOZNTTCTUrxu82cwV0KR6AHNmp4X9PmNX8eQf4H1fG';
console.log('6: ' + encryptedfromSFDC);

var encryptedfromSFDCagain = 'Ed2oiBbyhZYm7P3kDvT7jYkg1p5e6Tb4xEEGaOPe/UznnZxEbr9pEmY6WVTWlWL6';
console.log('7: ' + encryptedfromSFDCagain);

console.log('8: ' + decryptString(encryptedfromSFDC));
console.log('9: ' + decryptString(encryptedfromSFDCagain));

function encryptString(clearText) {
	var encryptedText = null;

	var textBuffer = new Buffer(clearText, 'utf-8');
	var iv = crypto.randomBytes(16);

	var cipher = crypto.createCipheriv('aes-256-cbc', KEY, iv);
	var encryptedBuffer = cipher.update(textBuffer);
	encryptedText = Buffer.concat([iv, encryptedBuffer, cipher.final()]).toString('base64');

	return encryptedText;	
}

function decryptString(encryptedText) {
	var clearText = null;

	var encryptedBlob = new Buffer(encryptedText, 'base64');
	var iv = encryptedBlob.slice(0, 16);
	var textBuffer = encryptedBlob.toString('base64', 16);

	var decipher = crypto.createDecipheriv('aes-256-cbc', KEY, iv);
	clearText = decipher.update(textBuffer,'base64','utf-8');
	clearText += decipher.final('utf-8'); 
	
	return clearText;
}

 

We can run this code via command line and see that we encrypt the same value twice, get two different encrypted values which decrypt to the same value.  We also decrypt two different encrypted values which came from Salesforce and they decrypt to the same value.

Now you can talk securely back and forth between Salesforce and Node.js to your heart’s content!

Here is the full code on GitHub: https://github.com/danieljpeter/SalesforceNodeEncryption

 

 

 

Advertisements

A Salesforce Conference in Uruguay? YES!

TL;DR: Unbeknownst to many, there is a large, talented population of Salesforce developers in Latin America.  I had the privilege of making the long voyage to Uruguay to meet many of them, get to know them a bit, learn about their beautiful country, and bring them some Salesforce knowledge of my own.  It rocked! (skip to pictures at bottom)


Punta Dreamin’ – Strong Salesforce Community in Latin America’s Technology Hub

I was extremely fortunate to have the chance to speak at the first Latin American Salesforce Community Conference.  Punta Dreamin’ was held in the resort city of Punta del Este, not too far from the largest city in Uruguay, Montevideo.

The event was held at the elegant Hotel Conrad, which is right across the street from the beach.  This venue has all the needed amenities and plenty of room for future growth!  We gathered in a common, great room where we all shared the sponsor and speaker activities of the day.  There were no parallel sessions going on, just one experience.  It was a FOMO-free event! (unless you weren’t there at all)  As one described it, “One track in a continuous and dynamic show that integrates speakers, attendees, sponsors and the glamorous Conrad experience”.

There were a mix of Spanish and English presentations.  In fact, Angela Mahoney delivered the entire opening keynote in Spanish, and English in her first language.  Amazing!  Punta Dreamin’ was a technical conference, aimed primarily at Salesforce Developers and Architects.  This was reflected in the top notch content of the sessions, and even though my Spanish isn’t as good as it could be, I still got a lot out of the program.  By paying attention to the graphics on the slides and picking up 20% or so of the words, I was able to learn from all of the sessions.

I did some walking around the town before the conference to get a feel for the local vibe.  I noticed everyone drinking maté out of gourds with metal straws.  This highly caffeinated tea with a distinct flavor is enjoyed all over by everyone.  I think Uruguay is fueled by the stuff!  Luckily several of the sponsors brought some so we could try it.  This was just the ticket to get an energy boost before delivering a presentation to a packed house.

Uruguay is a wonderful country to visit.  I’m a little jealous of the Salesforce developers that get to live there.  Walking around and exploring revealed much of it’s charm.  Rustic houses, unique works of art, tranquil beaches, tasty and satisfying Chivitos, green pastures with bright blue skies, unselfish and welcoming people, even urban city life.  It’s easy to leave a piece of your heart there.

I had several great conversations with Aldo Fernandez, who is one of the folks responsible for “dreaming” up this dreamin’ event.  He described “El Maracanazo” to me, an important part of Uruguayan and Brazilian culture.  This was one of the largest upsets in the history of sports where Uruguay beat Brazil 2-1 in the 1950 World Cup.  This took a huge toll on Brazil.  It is described as being Brazil’s version of Hiroshima, it was that bad.  Yet on the flipside, it instilled a strong sense of ability to achieve amazing things within the Uruguayans.  To put these countries in a US size perspective, Uruguay is smaller than the state of Washington and Brazil is almost the size of the entire United States!  Punta Dreamin’ was not El Maracanazo, there was no tragic loser.  However, I felt the spirit of that small country and its confidence in its ability to be a world player fueling the success of this conference.

Uruguay certainly has its share of talented software developers.  It was a pleasure getting to meet some of them.  They are a 7,000 mile flight away from the Bay Area, and in the Southern Hemisphere of the world.  Perhaps this geographic separation has something to do with the lack of global awareness.  But there is no denying they are a major exporter of “nearshoring” software and IT services for many other countries with the highest per-capita numbers for this in Latin America.  Uruguay has become Latin America’s outsourcing hub, with companies like Tata Consultancy Services setting up their Spanish speaking headquarters there.  There are also many tech companies headquartered in Uruguay doing their own work, and a growing startup scene as well.  A country with low crime, natural beauty, smart people, and amazing technology resources.  What kind of well-guarded secret is this place?

Now, the secret is out!  Punta Dreamin’ was a huge step forward in making this known within the global Salesforce community.

Traveling is learning.  Meeting new people is learning.  Being a software developer means you can never stop learning.  No matter how skilled you are, there is always more to learn.  One of the great things about these conferences is the opportunity we get to cross-pollenate technical and cultural knowledge between communities.  I presented a session on an open source project I’m working on called HyperBatch.  One of the attendees who saw the presentation reached out to me to say, “Thank you for coming this far South to talk and inspire our thoughts about what’s actually possible”.  That clinched value of me participating in this event right there.


Salesforce Culture in the Extended Ohana

Salesforce has the four core values of Trust, Growth, Innovation, and Equality.  I can frame my experience as a speaker at this Latin American conference within these values.

Trust

I trusted the travel would be worth it, they trusted I would bring value to the event.

Growth

I grew personally from the experience, while attempting to grow the awareness of the Latin American Salesforce Community.

Innovation

The Punta team innovated this entire conference, it was the first of its kind.  I was sharing my own innovations with the group as a speaker.

Equality

Latin America’s Salesforce professionals deserve equality of recognition and compensation.  They deserve a conference, too!  As a visitor to their country, I was treated with equality and felt welcomed.


Sponsors

The sponsors of this event were amazing.  I didn’t get a chance to talk to all of them, but I did get to most of them.  I loved talking with these folks so much, I am listing them here so you can check them out for yourself.  These are world-class organizations with some of the friendliest people you could ask for.  Have a look to learn more about Uruguay tech.


Additional Reading


Fotos


 

Snowforce 2017: The Salesforce Crossroads of the West

There are over 15 Salesforce community conferences now, but Snowforce is one of the oldest. Based in Salt Lake City, Utah, it has a large and growing group of loyal followers. Utah is quietly becoming the next Silicon Valley. It’s been named the Silicon Slopes, and increasingly it’s got the numbers to back it up. Don’t overlook Utah, it’s going through a tech boom, and Snowforce is a great way to network and learn from the folks who are part of it.  Read on to hear about my experience at Snowforce!

The night before the conference, there was a speaker / sponsor dinner. These extra activities are so important because the day of the conference flies by so quickly. Many times this is your only chance to talk to certain people (Peter Coffee for example). I met some new folks and got a chance to talk to them in a fair amount of depth. I also got to re-acquaint with familiar people which I hadn’t seen in some time. Finding the venue was a test of our navigation skills, as it turns out the “Red Iguana” can mean many different places in Salt Lake City 🙂

Checking into the conference was a breeze. Since it was downtown this year, it was a short walk from the hotel. The venue was one of the coolest I have been to. “The Depot” is a train station converted to a music venue. Hosting Salesforce rockstars in a place that hosted literal rockstars is quite befitting.  TrailheaDX did something similar at the Warfield. It’s a nice alternative to traditional convention centers.

 

 

 

Peter Coffee’s keynote was thought provoking and flawless as always. Prior to the conference he used a poll to crowdsource the topics. This meant he ended up talking the most about topics we were most interested in. Way to be customer focused! I’m still processing these important ideas. No doubt they will help my career, and maybe even help the world a little in the process. He really makes it worth getting out from behind your desk and flying across the country to expand your mind.

One difficulty with a conference this size is that there are 3-4 parallel sessions going on at once. Inevitably this means you will have a feeling you are missing out on the sessions you aren’t in. My advice is to accept you are going to miss out on many sessions.  Be comfortable in the session you have chosen and experience the session you are in with elevated mindfulness.

I think this is the first community conference I have been to that provided it’s own mobile app!

                                

This was a private social network, similar to the Dreamforce app.  I saw a lot of people interacting on this who weren’t on twitter, so this makes it a valuable addition to the conference in my opinion.

I enjoyed the SalesforceDX presentation by John Vogt and Wade Wegner. This is a massive and ever-evolving body of knowledge, so it’s important to stay informed. I especially loved Wade’s demos. He really puts the X in DX by showing how quickly you can build apps via the new CLI tools. Marc Benioff even got wind of this presentation and retweeted what was going on in the room!

Kevin Poorman (aka codefriar) showed off his innovative “Apex Promises” project. This looks like a great architecture to build robust processes that are long running and/or use multiple callouts.

The sponsors had their own room which seemed to be getting plenty of traffic. I popped in a few times and it was always packed with attendees. My company, Kenandy had their team in there giving away swag and answering questions about our ERP built on the Salesforce platform. It was also great to catch up with other sponsors like Coveo, who generously helps to pay for the video production at the Bay Area Salesforce Developer Group.

Lunch was included as part of the conference by gourmet food trucks out in front of The Depot. It was a little tight for space, but the food was excellent. Salt Lake City has no shortage of good eats! It’s really cool being able to create your own lunch experience by perusing around the trucks and choosing whatever looks good.

 

After lunch, a new Salesforce MVP, Adrian Larson presented his LimitsProfiler project. This solves a problem which is a bit of a dark art to many Salesforce Developers – performance. You can refactor code and gather data on how you have affected the performance of it. Cool!  I also found out Adrian is one of a very small number of moderators on Salesforce Stack Exchange.

 

Morgan Robertson, a Technical Architect at Eide Bailly gave a useful demo on Custom Metadata types. It was an end to end demo of a commission calculator app where the commission tiers are stored in Custom Metadata Types. The best part?  All the source code is available here: https://bitbucket.org/eidebailly/custom-metadata-example.

Who says work can’t be fun? I invited the Simplus SaaSquatch to come to my session on HyperBatch and it showed up! It even had a few words for the audience. Something to the effect of “hwooo uuugh oooowah woooo uuuuah”. The ‘squatch even came equipped with some foam snowballs we got to throw around. Hopefully it learned a few things about Salesforce in the process.

Similar to last year, Snowforce had a closing keynote packed with great life advice. Mark Widmer, Ph.D. from BYU gave us meaningful advice on how to live a great life. This focused primarily on myths and truths about how to increase your happiness. Mark has a lot of experience in outdoor team building activities, so his talk dovetailed perfectly into Snowforce’s day 2 activities on the slopes! Work-life balance is so important, kudos to Snowforce for incorporating this into the conference.

There was a closing happy hour event, a great opportunity to connect virtual relationships to the person in real life and discuss what we learned that day. It was also a chance to assemble a large group of us to grab dinner. Dinner presented a new opportunity exchange life stories which add whole new dimensions of depth to business relationships. Everyone has an amazing story when given the chance to share it.

The second day is an entirely different experience. This is what puts the “Snow” in Snowforce. Conference attendees meet up at the Solitude Mountain Resort and decide how to spend the day. There is a lodge provided as home base with food, drinks, and space for hanging out. Groups of people form organically for all types of snow activities from here. I chose to try snowshoeing for the first time with a few other people, which proved to be a very rewarding experience. Sun, snow, and majestic scenery set the stage for a challenging, shared experience for us to connect through.

There are a lot of people I’d like to give a shout out to for making Snowforce 2017 such a wonderful experience.  But rather than risk missing some folks, I’m just going to say if you are reading this, then you know who you are.  Thank you!

French Touch Dreamin’: Where We All Speak Salesforce

NOTE: Before reading any further, start this song playing for the proper ambiance:

Music playing?  Great, read on…

img_0405

 

You may have heard of Midwest Dreamin’, Tahoe Dreamin’ or some of the many other Salesforce community conferences which may or may not have the Dreamforce-esque “Dreamin’” in their title.  Now you can welcome French Touch Dreamin’, a community event in Paris, to the lineup.

They could have simply called it France Dreamin’, or Paris Dreamin’.  But French Touch Dreamin’ conveys the spirit of the way in which the organizers of this conference infused it with their touches of France.  This delivered a very French experience!  The song you are listening to right now is also of the “French Touch” dance genre.  That might just explain all the great music which was played throughout the conference as well!

img_9701Two days before the conference I had a meeting at the Salesforce France headquarters.  They are housed in a modernized, historical building with the best view of the Eiffel tower imaginable.  Thanks to Jean Michel Mougeolle for helping to set this up.

 

img_9790img_9977The night before the conference we had some preliminary gatherings such as Happy Hour put on by Holly Goldin Firestone and a Speakers Dinner.  These activities were an excellent chance to catch up with folks in the Salesforce community and get some hints of what the conference the next day was going to be like.  I was thrilled to get to sit with Peter Coffee and Shivanath D. at the dinner.  There were brilliant conversations going on all around the table that night!

Thursday morning kicked off with a surprise musical introduction:

img_9806

And an enlightening community-themed keynote by Holly Goldin Firestone:

18 world class sessions went on throughout the day in 3 different locations at the super cool Pan Piper venue.  This venue was not only perfect in terms of size and layout, but also had the French Touch!  These sessions were a great opportunity for thought leaders to share their content with a worldwide community, in person.  I learned a ton from the sessions that I saw, and especially appreciated the diverse perspectives.

img_9960
(photo courtesy frenchtouchdreamin.com)

I had a great time presenting my session on HyperBatch.  The A/V support was excellent.  They had a remote clicker and plug-in internet available which were the icing on the cake.  I got some great questions from the audience, and I look forward to my project being used by the Salesforce community.

 

img_9798In between sessions there was plenty going on:  sponsor exhibitions, French food, wine, and coffee, a DemoJam, Trailhead Contest complete with buzzers, photo opportunities, and an outdoor patio area.  The day flew by really quickly with so many great options for things to do.

 

img_9934The one and only Peter Coffee gave the closing keynote.  Peter is one of the most recognizable Salesforce personalities, and has interviewed the who’s who of the Salesforce ecosystem.  He’s even interviewed the founder of Kenandy!  This was not your typical, glossy, “everything is amazing” type of presentation.  Peter took a hard look at many trends he is seeing, and gave us concrete advice on how to move ourselves and the industry forward.  This honest look at things was refreshing, and provided serious value to the attendees.

It goes without saying, the organizers really outdid themselves on this event.  If you were thinking of going in 2016 but didn’t make it, don’t miss it next year!  I’d also like to extend a personal thanks to the sponsors.  Without them, these types of community events could not exist.

img_99492016-11-27_21-14-32

 

 

Although it was a European conference, there were attendees and speakers from all over the world. People from 13 different countries were there!  The organizers decided to use English as the common language at the conference.  But I say that we were all united by the common language of Salesforce.

img_9975

For more information

 

 

 

Tahoe Dreamin’ 2016: How Less Can Give You More

Dreamforce is THE software conference.  Period.   I’m a long-time, repeat attendee, and I get a huge amount of value out of it each year.  However, I always walk away feeling like I missed out on most of it because there are so many things going on at the same time.  There are always 3 events I want to attend which are starting half way through an event I’m already sitting in and don’t want to leave because it is sparking innovative new ideas in my mind.  And then what about that list of people I promised I’d meet up with, where do I squeeze them in at?  Sleep is required, yet also optional in the face of so many extravagant parties going on.  If you’ve been there, you know exactly what I mean.  It’s an accepted side-effect of delivering massive amounts of awesomeness in a short period of time.

What would it be like if you took a sprinkling of the same attendees and speakers, and put them into a Salesforce conference where you gave the sessions and events a little more time and space to breathe?  What if there was a venue with a framework which set the tone for like-minded people, but left opportunity for serendipitous experience?  What if you could throw agenda builder, and google calendar out the window for a weekend and still feel like you got everything done and more?  It is possible, and I just experienced this at the inaugural Tahoe Dreamin’ 2016.

This was the first time I’d been to a community-organized, regional Salesforce conference. Knowing the value of diversity of experiences, I had been wanting to check one out.  This one was in my backyard, so it was a convenient way to make it happen.  The cost was very low as compared to Dreamforce.  It was more about justifying taking a couple of days off from work.  I decided to present a session there which made the justification easy.  It was an opportunity to share some knowledge and give back to a community which has afforded me a rewarding career, which I am very grateful for.  As well as create some awareness for the company I work for, which has been a catalyst for my career, which I am also grateful for.  Building a full-blown ERP on top of Salesforce has been a trial by fire, which has made doing almost anything else on the platform seem easy by comparison.  There is no substitute for that experience, and I love sharing the battle stories of doing that with the Salesforce community.

I decided early on I should rent a snow-ready vehicle and share the cost by carpooling.IMG_1166  This way we wouldn’t have to worry about chains or getting stuck in the snow.  This was probably overkill, but I liked the peace of mind of being prepared.  Bill Greenhaw matched up carpool providers with those in need of a carpool, and this worked out great.  Carpooling was smooth and enjoyable and allowed me time to get to know the people riding with me.  I had admins and developers with me who were all doing very different and interesting things with Salesforce.  This was a great learning experience.  When I picked up my first passenger, this is actually when the conference started to begin.

I arrived Thursday night and rushed up to my hotel room in full Dreamforce mode to plan my agenda for the night.
IMG_1167 IMG_1168 IMG_1169
I quickly realized there was only one thing going on.  Wow, that was refreshing!  No guilt about missing out, and a chance to meet everyone.  The event was sponsored by Shonnah Hughes & Toya Gatewood.  They did a great job of providing a happy hour style meetup which gave me the chance to meet many new people such as Katie McFadden and Stuart Edeal and consider aspects of Salesforce I don’t often think about in my daily routine.  It also gave me a chance to catch up with people I already knew, and felt like I knew from online interactions.

The next morning I woke up early to go downstairs for coffee and ran into Zachary Jeans.  We had a nice, long, slightly philosophical conversation over some Starbucks.  A great example of Tahoe Dreamin’ serendipity.  Once I was primed with coffee, I put on my #AlohaFriday shirt and sat in on some great sessions.  Adam Seligman and Shawna Wolverton upped the “juvenile marketing” ante and rocked the house with deliciously tacky, retro ski outfits.
CZVxPlMUAAE4sfTIMG_1170
They gave us lots of great content such as unpublicized features way out on the roadmap.  Team ButtonClick,  Mike Gerholdt and Gillian Madill were at the keynote as well, helping to run the video of Parker Harris and Alex Dayon wishing us all a happy Tahoe Dreamin’.  I ran into more people I wasn’t expecting to see, such as Stephan Paquet, a first-rate developer from the North Bay Developer User Group I used to run.

All the sessions I attended were Dreamforce quality or better.  Yet there was something different.  The speakers, myself included, were more relaxed, confident, and open to questions.  IMG_1187Perhaps it was due to the absence of scheduling overload, or the fact the sessions weren’t recorded.  Whatever it was, I liked it, and I’m pretty sure everyone else noticed it as well.  I attended mostly developer sessions, and got plenty of takeaways to justify the trip.

I had diamond in the rough “ah-ha!” moments while Samantha Ready talked about Lightning Out while simultaneously pulling off an ambitious, live demo on hotel wifi.
IMG_1175IMG_1184IMG_1181
Listening to Pat Patterson talk about Forcecraft (Salesforce integrated with Minecaft), I finally gained an appreciation for the concepts it represents, something I never got the chance to do at Dreamforce due to schedule overload.
IMG_1200IMG_1198
Daniel Hoechst showed some tools for Continuous Integration which helped to validate the concepts I use myself at work.
IMG_1202IMG_1205
But between these sessions is where the magic had a chance to happen.  There were 15 minutes, sometimes an hour between them. This free time could be used to hang out in the room and talk with the presenters, converse with the people next to you, meet up with groups of people outside the room, stop by the exhibitors in the trade show area, or hop on your selfie bandwagon of choice.  There was amazing food and drinks o’plenty, which kept the day and the conversations flowing.  There was no excuse to leave if you didn’t want to.  The pacing of the sessions, breaks, lunch, happy hours, was varied, and in my opinion, perfect for a conference like this.  Taking a play from Foo Camp’s playbook, they gave us a canvas and paint to create our own masterpieces.  However, the figurative paint by numbers or even magazines were still on hand for those who prefer more structure.  The key takeaway here is that less actually leads to more.  Passionate attendees can fill the space better than event planners when given the opportunity.  And therein lies the beauty of the community conference.

Dinner was a fancy sit-down affair with a buffet of some of the best food I’ve ever eaten.  The dinner alone was worth the $100 ticket price of the entire conference.  It included plenty of time to talk with your neighbor or switch tables and talk to other people.  There was an impromptu toast to Bill Greenhaw for pulling off such a successful event, as well as some valuable prize giveaways.

After the event the attendees were free to put away their lanyards and badges and explore the nightlife of the area.  I wound up in a live music bar with 10 or so other folks from the conference.  IMG_1214Some I had met that day, others I had already known.  This was a refreshing chance to NOT talk about Salesforce and instead enjoy the fact that we are also people who do things other than sit in front of computers.  Such as listening to a cover of the Eagles with a cold bottle of beer.

Saturday was the Tahoe Dreamin’ fun day.  There was quite a list of activities to choose from.  I chose to try snowmobiling, since I’ve never tried it.  IMG_1221I ended up in a group with Zachary Jeans, Pat Patterson and his family, and Jean Michel Mougeolle (he came all the way from Paris, and gave a session that was the talk of the conference).  It turns out snowmobiling is some of the most fun you can have without breaking the law.  It was like being in a Speeder Bike scene out of Star Wars.  We climbed the deeply snow-covered hills from 7000 feet to 9000 feet on what are mountain bike trails in the summertime. Up and down hills, speeding around curves, never knowing what we would see next.  The mix of adrenaline from the ride, and the breathtaking scenery you get to see is difficult to put into words.
IMG_1224 IMG_1234 IMG_1236 IMG_1237 IMG_1240 IMG_1241 IMG_1244 IMG_1245 IMG_1250 IMG_1255 IMG_1259 IMG_1261 IMG_1263 IMG_1272 IMG_1285 IMG_1293 IMG_1297 IMG_1299
Photos do not do it justice either.  Emerging from the wooded trails into panoramic views of Lake Tahoe thousands of feet below you, in potentially deadly weather, was a religious experience.  You couldn’t help but high-five the people around you.

After coming down from the snowmobile high, Jean Michel Mougeolle and I got a nice lunch at a cafe.  I learned more about the innovative image platform he is building, delivered in his wonderful french accent.  I think it made my lunch taste better.

We met up with Zachary Jeans, Eric Dreshfield, and Stuart Edeal for gondola ride to the top of Heavenly.  We relaxed and enjoyed the scenery around us as the cable pulled us high up the face of the mountain, and everything below got smaller and smaller.
IMG_1306 IMG_1312
We stopped at the observation deck for awhile and tried not to freeze to death while we took some photos.  The protip for survival was keeping the icy wind to your back.IMG_1319 CZcx822UsAIDIsu
We then got back on the gondola and continued to the ski lodge. The lodge and surrounding areas were bustling with 100s of skiers and snowboarders.  We took the opportunity to duck into the lodge and thaw out with a round of coffee.
IMG_1321 IMG_1324 IMG_1325 IMG_1327
While inside the lodge, the conditions outside got progressively worse.  We finally were alerted we needed to get off the mountain before everything shut down.  The trip down was a chance for some more reflecting on the day and joking around.

Once at the bottom I gathered up my fellow carpoolers, said goodbye to Tahoe, and we drove back to the bay area in the dark of night.  This was another opportunity to have some in depth discussions on the nuances of developing on the Salesforce platform and learn from each other.

Did the sponsors of Tahoe Dreamin’ go home with hundreds of qualified leads?  Probably not.  Was there a Tesla raffled off?  No.  But was this conference a complete and total success in the areas that matter the most?  Without a doubt.

Salesforce development struck by Lightning

One of the biggest bombs Benioff dropped (say that 5 time fast!) at Dreamforce 2014 this year was Salesforce1 Lightning:

salesforce1 lightning

 What theblue-lightning-hi is Lightning?

Not unlike the announcement of Salesforce1 at last year’s Dreamforce, Lightning has a lot of marketing hype and ambiguity.  This is due mostly to the fact it includes a suite of products.  However, also like Salesforce1, there is a piece of the offering that stands WAY out as the most important.  When all the dust settled around Salesforce1 it was the mobile experience that proved to be the real offering.  With Lightning it is going to be the new component framework, essentially the next generation of Visualforce, that is the real crown jewel.  The schema builder, process builder, and lightning connect are all awesome, don’t get me wrong, but they have been around in one form or another for awhile, and are just incremental innovation with rebranding.  The lightning app builder is also awesome, but it is just a tool for implementing the component framework in a WYSIWYG fashion.

New component framework?  What about Visualforce?

Well, what about S-Controls?  The one sure thing about technology is it is outdated as soon as it is released.  S-Controls made way for Visualforce.  Visualforce has had a long run in the life of force.com development, but is really starting to show its age.  In recent years ISVs and customers have had to deviate more and more from the strict Visualforce components to meet their requirements.  JavaScript frameworks have been creeping into Visualforce pages to the point where Visualforce tags are becoming a minority of the code in a page in many cases.  Controller extensions, viewstates, page refreshes and synchronous processing are victims of attrition.  They are being turned into museum pieces by more efficient user interfaces using JavaScript remoting, static methods, stateless behaviors, asynchronous processing.  Technically this is still a “Visualforce Page”.  But the composition of that page looks very different today then it did say 3 years ago.

Ok…  So, still why not keep using Visualforce?

Square Peg in a Round Hole_0565

In 2 words:  Mobile and Wearables.  Visualforce was designed for desktop computing with relatively fast, hard-wired network connections, large displays, and a full-fledged human interface devices.  Salesforce1 was a huge leap forward in addressing the needs of mobile computing.  But it left a gaping hole which developers had to attempt to fill as best they could.  Developing Visualforce for Salesfore1 is not an amazing experience.  Sure they threw us some bones like sforce.one.navigateToSObject.  But the architecture and styling just felt like a square peq in a round hole.  It doesn’t have that desktop Visualforce / Apex, Peanut Butter / Jelly meant to go together feeling.  Put another way, the Salesforce1 deficiency was the ability to create Salesforce1 mobile experiences in the same way salesforce created them “out of the box” on the Salesforce1 mobile app.

Salesforce1 Lightning to the rescue!

For sure the Visualforce pages of enterprises across the world will continue to be read and write data from and to the salesforce orgs they live in for years to come.  But no longer will Salesforce1 mobile app development have to feel like desktop shoehorned into mobile.  The beautiful, mobile, standard page layouts of Salesforce1 will flow more gracefully into custom Lightning apps.  <ui:button> will magically be the right button for Salesforce1 without needing to disguise <apex:commandButton> for the job.  Developers won’t be forced to go to other JavaScript frameworks every time they want to do something on the client side.  In a nutshell, Lightning allows us to go back to developing in a more streamlined “Visualforce-esque” manner, while still being able to leverage the latest technologies of the server and perhaps more importantly, the client.

Will the legacy desktop user interface go away?

I don’t know.  But there will definitely be new apps created with Lightning in a responsive fashion to work seamlessly across desktop, mobile, and wearable devices.  This is at least the start of a shift towards one UI to rule them all.  The {!$Browser.formFactor} global variable will let developers slightly customize their apps to work best on different devices.  One app customized for all platforms is much easier to maintain than a Visualforce desktop codebase and a Lightning Mobile / Wearable codebase.  The trick is doing it in a way where the experience isn’t compromised on any device.  This is hopefully where Salesforce will come in and handle the the lightning elements in different fashions depending on whether the Lightning app is run through the Salesforce1 mobile app on a smartphone, or through the desktop.  For example, a data grid that is smart enough to render differently for large vs. small screens without the developer having to handle that.  This also helps developers to “future proof” their code since salesforce provides an abstraction layer which they maintain so your app always works well on the latest devices.

Advice to other Developers

You need to have at least intermediate level JavaScript experience.  If you don’t have it, get it.  Read a book, take an online course, or just google your way through some complex JavaScript projects.  Don’t focus just on standard JavaScript syntax, but frameworks like jQuery, various patterns, CSS and the DOM as well.  JavaScript is going to become a KEY skill for salesforce developers (it already is in many cases).  This will not only improve your ability to crank out hybrid Visualforce pages, but it will also make the move to Lightning less of a shock.  It will also position you well to be create interesting new projects on Lightning vs. being stuck a role maintaining Visualforce…  And we all know building new things is more fun than maintenance.  🙂

Salesforce1 Lightning Resources

Adding Reports to Salesforce1 with jQuery Mobile and the Analytics API

Salesforce1 comes with nice dashboards built in, but no reports!

This is somewhat understandable.  Dashboards are already fairly mobile friendly while reports can be quite unwieldy, even on a desktop experience.  The number of rows and columns and the controls needed to manipulate them are not trivial to implement on a small touch screen.

It is, however, possible to attempt to build this functionality yourself with the Salesforce Analytics API and whatever User Interface you wish.

Arun Varadharajan, Product Manager for Salesforce Analytics has put out a nice, simple example of how to do this:

Check the link in the tweet to see his GitHub repo.

This example is cool because it uses no apex controller.  It is all done in VisualForce and JavaScript.  It renders with the Google Charts API, to make something that looks like this:

11

However the Google Charts API isn’t all that mobile friendly.  And this example provided no method for choosing which report to display.

I decided to look deeper to push this solution further ahead for the salesforce community.

My Contribution… sf1Reports!

sf1Reports uses the latest jQuery mobile framework to create a mobile-friendly report search and render experience.

The search uses JavaScript Remoting and SOSL to return the results as you type. It searches all your reports you have created in your salesforce org:

3

You can choose 2 modes to render the report.  Reflow or Column Toggle.

See these links for more info:
jQuery Mobile 1.3.2 Docs – Table Reflow
jQuery Mobile 1.3.2 Docs – Table Column Toggle

Reflow mode will look like a standard table when the columns fit on the screen, or will collapse the rows down into a block of label/value pairs when they don’t fit on the screen.  Reflow mode is good for looking at the report data one record at a time, but not as good for comparing the records to each other:
4

Column Toggle mode lets you select which columns you want to display, so you can fit the relevant columns onto your mobile screen:
5

Installation Instructions

Grab the files from my GitHub repo: https://github.com/danieljpeter/sf1reports .
Deploy the 2 classes and 1 VisualForce page to your salesforce org. I didn’t package them, but they are easy to deploy with something like the Force.com IDE.

Enable Salesforce1 in your org:
6

Make sure the mobile checkbox is checked on the VisualForce page:
7

Make a VisualForce tab for the page:
8

Add it to the mobile navigation:
9

Navigate to https://<your instance>.salesforce.com/apex/sf1reports by manually entering it in the URL bar.  It will change to your visualforce domain which will look something like this:
https://c.na15.visual.force.com/apex/sf1reports . Copy the visualforce domain portion of the URL as seen below.  You will need to paste it into the next step.

Take your visualforce domain, and add it to remote sites.  this is because we will be calling the rest API:
10

Final Notes

This is just v1.0.  It obviously is just a crude start, but it has potential.  Feel free to contribute to make it better.

It only supports tabular reports currently.  Summary and Matrix could be added with some more work.  I use the JSON Parser to blast through the Analytics API response.  That data is fairly complex, so I chose to iterate over the JSON rather than try to deserialize it.  There would need to be some thought as how to convert the JSON for Summary and Matrix reports to corresponding apex and ultimately HTML elements.

I chose a flat listing of all reports that is searchable by SOSL.  This seemed like a good mobile-first thing to do.  If desired, navigation through the report folders could be added.

It might make sense to make some mobile versions of reports in salesforce with a naming convention which have fewer columns and rows.

I noticed that the iOS Salesforce1 app would crash sometimes.  The Dreamforce 13 app also crashed in a similar manner, so I don’t know if it is a problem with my app or not.  Sf1reports didn’t crash which running it in a browser on my desktop with the /apex/sf1reports URL or the /one/one.app URL.  Hopefully Salesforce1 proves to be a reliable container for our custom VisualForce apps and this isn’t an indicator of a larger problem.

If you need report data on to go, it might just solve your needs!