Coming to Grips with False Value

This may come as a shock to you, but I wasn’t always this shining example of cool you see before you today. No no no, quite the contrary. It was my utter lack of cool (perceived or otherwise) that has led me to this post today, but put a pin in that for a moment.

When I came to the Salesforce world, I was admittedly in a very dark place in my life. It’s not proper of me to go into detail here but suffice it to say, I felt like I had little value to the world, and yes even to those around me. It was hard to get up and go to work every morning, and once there is was hard to do and be motivated about said work. I muddled through because I had a family that depended on me and that is quite likely the only reason I didn’t do something drastic.

You see…I grew up in a rather small town and suffice it so say I was NOT one of the popular kids. As a matter of fact from a very early age, I was a target. My parents divorced when I was young so I was attached to my mother’s hip, shy and not exposed to much of the things that boys were “supposed” to get exposed to. My family was also very religious which wasn’t exactly a popular thing to be in school either. On the list of uncool things to be in school, I had many checkboxes filled in and most of classmates simply would NOT let me forget it; save for a small core of close friendships, I really had nobody.

I was also the small kid…easy to throw around by anyone who sought to establish their dominance in front of opponents. I wasn’t shoved into lockers and nobody ever drew blood thankfully, but the few times I stood up for myself, resulted more in laughter than deterrence. When you have constant experiences like this day after day, it really causes one to question their self worth.

Fast forward to my professional life. I was relocated early on in my career to the Chicago area and while I did manage to meet my wife and grow my friendship circle a little, I still carried with me the imposter syndrome, not of my work personality, but “who I really was” — I didn’t want anyone to really find out my background. That any persona I put forth was really just a mask that covered up my past as a “loser.”

Eventually I went on to do all the things: get married, have kids, etc. and during a particular rough period in my life I hit rock bottom — well rock bottom for me, hindsight being 20/20 I was still a very fortunate person with much to be thankful for, but when you’re in *that* place, you don’t see it.

Then as I started to pull myself out of some of these dark places, I took a chance and changed my career trajectory forever when I accepted a position at a colleagues consulting firm. It was just a tiny firm, three of us but it was going to introduce me to a community that I credit to this day with saving my life (I told you — a dark place).

In 2014 I wrote a silly Salesforce song called “That’s Why Admin’s Drink” and it kinda went a little crazy in the community. Suddenly I found myself going to events and posing for selfies, people were excited to meet me, to hang out, etc. For once it seemed that I’d found my home. This led to cofounding Apex & the Limits (a parody band that produced derivative works for popular songs and adding Salesforce related lyrics) and for a brief time, we were well known in the Salesforce community; opening up for Benioff at the first TrailheadDX, performing in the Dreampark at Dreamforce, etc.

I suddenly saw myself as having in some way, shape, or form…value. Not just value to a small group of folks, but (it feels gross to even say it) I had fans in a way. I went from no friends, to having actual fans (I actually signed an autograph at one point…). I think this is where things went a bit off the rails for me.

I have fallen into the social media trap: “oh look, I have 4,000 followers” (well I did at one point) and while that is not even a fart-in-the-wind — for someone like me, it was a ton. It became something that I could point to and think to myself, “lookie here assholes [from my past], I *am* somebody!” (maybe a little somebody, but those folks that pushed me around in my high-school days don’t exactly have people asking them for selfies and recognizing them). To me – that was a bit of vengeance.

I’m not sure what that really *makes* me? A narcissist? Probably. Shallow? I feel like that’s a yes. Someone with an over-inflated ego? Yep, check that too I suppose. (I also know I’m my own worst critic, but again a history of feeling of little value to anyone makes it very hard for me to even remote *think* of myself in this manner). Be that as it may, its who I am, and who I have become.

So why am I sharing any of this?

I’ve found myself glued to social media and while I was able to escape the Facebook trap nearly 10 years ago, the Twitter one is one I’ve always held dear (I joined *very* early on). MUCH has happened to me while on that platform and to be quite honest, it has inflated (falsely so I believe) my feeling of self worth but I won’t lie, it felt good to feel that. In light of recent events, I would like to leave Twitter behind me (I still refuse to call it “X”). Its very hard for me to let go and I will be doing so in stages.

I must be cautious because while you can find me on BlueSky (lifewithryan.bsky.social), and Mastodon (@lifewithryan@toot.community) I can already feel myself falling into the same tendencies I had and have tied to Twitter. Nonetheless, I feel the time has come for me to pull back from Twitter as it has become such a divisive collection of hate, conspiracy theories, and misinformation. For now, I’ll simply just stop interacting. I’m sure I’ll occasionally check in to ensure that those who have not yet made a move to another platform aren’t trying to reach out, and ultimately will one day come to terms with simply closing it and having my data deleted, etc. I’m just not there yet in my personal journey.

I tell you all of that partly because it is cathartic for me to finally admit that I loved the attention, and to come to grips with realizing that the number next to my handle means nothing, (that’s not to say I’m not thankful for each an every engagement and follower, etc.) but mainly because I’m learning social media is actually dangerous — at least for me, and now I believe, for our country. A move to Bluesky and/or Mastodon is a chance for me to reset my beliefs and expectations and begin to re-engage with a community that has meant so much to me since I stumbled into it 11+ years ago.

I’ll see you all (hopefully) in one way or an other, somewhere.

:wq!

Transitioning to #Lightning from Visualforce

You’ve heard me say it before: I was jaded. I was looking back at 20+ years in I.T most of that as a developer in various languages and “frameworks of the day.” I was tired of the same thing, and even my transition to the Salesforce platform brought very little actual excitement for me. The community helped me see past all of that, which is why the community is still my favorite thing about the ecosystem, but as a developer, I was still…well I was cranky!

Then Salesforce introduces #Lightning. Suddenly I was invigorated again, something new, something that was in line with what all the “cool kids” were doing. Something forward-looking, and I got excited again. I dove in and started working, which brings me to my first tip for making the leap from Apex/VF to Lightning.

#1. Jump Right In — One of my favorite bands today “The Zac Brown Band” has a song called “Jump Right In” and you could say I took that to heart. I closed my eyes, picked a random deity, said a prayer and leapt from the lion’s head smack-dab into writing some lightning components. I suppose I’ve always been a learn by necessity/trial by fire kinda person and that seems to work for me. So if it works for me, it might work for you as well. Spin up a developer org, turn on lighting, and start writing something, anything! My first foray was a streaming application that ran via the web and in Salesforce1 that allowed users to vote on what they wanted for lunch. As they voted, the counts went up in real time. Meaning person A voted for sushi from their phone, and persons B,C, and D all saw those updates happen in real time on their screens. I was jazzed, and I was hooked! Was it useful? Not really, but that’s not what matters. What matters was that I learned something. So just “Jump Right In” and do something.

#2. Ask “What If” — since your jumping right in with both feet anyway, start asking yourself “what if?” What if I try to add something like a streaming (see above) result to a lightning component? What if I change this line to that? What if instead of creating a component on the record detail page to modify a field on that same object, (because you could do that), I created a reusable form to create child components directly from the parent’s detail page without having to leave that page? Ya know, like this:

#3. Check out Lightning Design System — When thinking about moving some functionality from Visualforce to Lightning, think about your options. Maybe your first option isn’t a component at all, maybe its simply re-styling your Visualforce page using the Lightning Design System. (This thing is awesome…just awesome). If you’re at all like me at hate front end work, the perhaps the Lightning Design System can ease your pain somewhat. They’ve taken all the things I hate about CSS and put them together in a not so blackbox “blackbox” that just works. All you have to do is apply the appropriate styles to your HTML elements and the system takes care of making it look like the page is inside LEX. Yea, I’m gonna say it…it’s sexy.

#4. Lightning Out — Maybe you’re not quite ready to go full on lightning components. Maybe you could instead replace pieces of functionality with a simple component and Lightning Out and throw that into a Visualforce Page. Lightning Out allows you to run lightning components right inside of a Visualforce page or even off platform if you so desire. (Something I’m really wanting to try but just haven’t been able to find that time yet, but mind you, I will indeed find the time). This would allow you to start small and work your way up.

#5. Get Involved — No surprise here. Me, the guy always raving about the community, is asking you to get involved with the community. Join your local developer group, go to user groups, participate in the Success Community, or the Salesforce Stack Exchange. Start helping other’s solve their problems. I promise, you will learn more than you ever thought you could, and there’s so much to learn. I’m barely scratching the surface and if it weren’t for those in the community already doing the things I’ve mentioned above, I’d be nowhere. Ya hear me? No. Where. The community is the secret and we are all here to help. The blogs, the forums, the user groups, the conferences, all of it. Just do it.

:wq!

Time For Giving Thanks

I know, I know…I KNOW — its been awhile since I last blogged. Ever since June I’ve pretty much been a one-man consulting shop and one has to pay the bills. Throw a couple of talks and a Dreamforce performance with Apex and the Limits in there as well as numerous gigs with a local cover band, and of course family duties, you have a recipe for disaster when it comes to keeping to a tight blogging schedule. (It may be too early for New Year’s resolutions, but I suppose one of mine will be to tighten this schedule up!)

But I digress — now is NOT the time for that. Now is the time to sit back and think about all of the things that are going right in my life. All of the things that I am grateful to have in my life. So that’s what I intend to do today…well not entirely, it will have a “mostly” Salesforce bend to it…somehow (I don’t plan these things, I write when I’m moved to do so…)

I was sitting at my desk this morning working on some validation rules and had our Apex and the Limits Dreampark performance going in the background. I was reminded of a moment during the last tune where I looked down at the gathering of community folks swaying back and forth in the front of the stage. I remember looking down at them all and thinking just how lucky I am to be able to share my strongest passion (music in case you didn’t know) with this incredible community. At that moment, on the stage — I was slightly….overcome…

img_3510

(no I didn’t cry, I was just sweating from my eyes…). That memory is what has sparked this entry, so not in any particular order, save for the first — THIS is my Salesforce Thanksgiving list:

1) The Community — I’ve said it again, and again, and again, and again and will keep saying it as long as I’m here, I LOVE THIS COMMUNITY. There’s nothing like it in the tech world that I’ve ever seen. Its why I keep coming back.

2) Apex and the Limits — as eluded to above, being a member of the band allows me to marry my passions together: Music, Technology, and this wonderful community (see above). I also get to share the stage with some incredibly awesome people: Rachel Rogers, Peter Chalmers, Mark Ross (and when we are lucky, Benjamin Bolopue, and Brian Kwong). Sharing the stage with these people — well, lets just say it feels like home :)

3) The MVPs, and the Salesforce MVP team that wrangles us all — for years…many years I’ve never really felt at home amongst other techies. Yes I was a techie myself, mostly self-taught and with that comes imposter syndrome like you wouldn’t believe. I was never an “academic” developer. I just got shit done, and apparently did it well, but not having that “academic” rapport with my peers pre-Salesforce, I always felt like I just didn’t belong. Then somehow I found myself getting to interact with some very smart, very giving, incredibly approachable and friendly people. I felt welcomed for the first time in my career. I still feel like an imposter, but nobody “makes me feel” that way. I’m so thankful to be able to call these folks friends! #Ohana for the win!

4) The Platform — I was a very jaded developer. Very cranky — tired of “the latest and great framework” type of mentality. Just barely feeling like you’ve mastered one before the next hot thing comes along only to jump in and find it half-baked. (Forget jumping into those communities to learn — again, see #1 above). With Salesforce, while they do innovate and come up with new features all the time, the whole thing still always feels very familiar. Yes Lightning was a big jump from Apex and VF but somehow it was so easy for me to accept this time, probably because I still have the rest platform goodies to lean on whenever I need to.

5) Trailhead — I mean COME. ON. Really? Really? You’re going to put all of this wonderful training material together, throw it up on the web, for free? For anyone to begin learning? For anyone to add to their existing skill set? To give people an option to learn something new and change their career, their LIFE!?! Oh and you’re going to make it fun to boot? Abso-effin-lutely! Sign me up. I may only have 32 badges (again #consulting) but Trailhead gives me a way to jumpstart my knowledge absorption when presented with a new task. I’ve even passed the link on to my sister in hopes that she can take it and learn. We’ll see — tech really isn’t “her thing” but ya never know. It’s zero barrier to entry, its fun, and its full of valuable information. If you haven’t yet signed in, do it! Today!

6) My local Salesforce peeps! — Salesforce lunches, User Group meetings, Dev Meetups, and hopefully I can make a #SalesforceSaturday or two after my daughter’s swim season is over. The group of folks are the heart of the community here in Wisconsin. I look forward to all the time I can possibly spend with them!!

With that — its time to retire for the week. To spend time with my wife and kids, watch them as their eyes light up when the snow starts to fall (those of you that know me, know that I HATE cold weather) but I’m thankful that my girls enjoy it so much. Their individual laughs are so infectious and if something as simple as snow brings them joy, then I can live with it.

Happy Thanksgiving to you all!!

:wq!

Dreamforce 2016 is Upon Us

As I sit in my home office preparing to start the day, I can feel my mind wander towards what lies ahead for me in just a few short days. I’m reminded of the fact that I’ve been the three Dreamforce events in the past three years and how each has been a completely different experience. It has me looking forward to my fourth Dreamforce and wondering what is going to be different this year.

Lets review for those that don’t know me:

Dreamforce 2013 — I was very new to the platform, just six months in as developer and had met my goal of becoming certified before the event. It was all very new, but I hadn’t been “plugged in” long enough to know anything about what to expect. I was overwhelmed by the sheer scale of it all and like most newbies, I tried to do too much. My first impression, in all honest was: “I don’t get what the big deal is” but the electricity at Marc’s keynote was definitely palpable and when he introduced one of my all time favorite bands — Huey Lewis and the News — the stock of this whole thing went up a notch. While still not completely sold, I traveled home knowing that somehow I’d landed in the right place.

Dreamforce 2014 — shortly before Dreamforce 2014 I started getting plugged into the community. I started to become more and more active on twitter and interacting with the community and discovered a hash tag “ThatsWhySFDCAdminsDrink” and it inspired me to write a song about it. With a sigh of apprehension, I submitted it out to the world and it was met with positive excitement. A few short weeks before Dreamforce I received a phone call from Erica Kuhl asking me if I’d sing my song to open her keynote session. I’d never really done anything like that before on such a grand scale and stage and was scared absolutely sh*tless, but pushing myself out of my comfort zone, I accepted her request. I was thrust into the heart of the community. Opening Erica’s keynote would soon prove to be the catalyst for a life-changing experience. Adding to this already incredible experience, I wound up getting to hang out with my developer twin for most of that week and it was experience Dreamforce (and the community) with her that led me to write what has been my most visited blog entry: “It’s the Community Stupid” and I still believe every word whole-heartedly.

Dreamforce 2015 — in spring of 2015 I found myself invited to join the Salesforce MVP program. I had continued writing more Salesforce based songs, stepped up my blogging, started interacting more on the Success community, etc. I was getting involved. I was volunteering for time in the Admin zone, I was meeting more developers, interacting with anyone that I could — and you’ve all heard me say at one time or another that I am not a people person really but this community really brings it out. Here I was, on my third Dreamforce and my third completely unique Dreamforce experience. I got to open the Dreampark karaoke show with fellow MVP Sarah Deutsch where I played guitar and she sang a couple parodies I’d helped her write. I got to attend the MVP event, and met so many more awesome people that I could never replace in my life. It was here at Dreamforce 2015 that Apex & the Limits was officially formed. We got to play a number of songs for the MVP party and while they were actual covers and not parodies, (that part comes later), we found ourselves becoming fast friends. I also got to be part of the admin comedy hour and sang my “Stop Doing Sh*t In Production” song on that stage. I had a horrible case of Dreamforce flu and things didn’t go exactly as planned, but it was still an experience I’ll never forget.

Dreamforce 2016 — This year will be yet again an entirely new experience for me. I’m speaking on Wednesday at 8:30 in the morning about custom lightning components. I am NOT a public speaker, sure I’ll play guitar and sing, but speaking publicly, as a source of some sort of knowledge to a room full of very knowledgable folks is very intimidating for me. It’d be like me playing and singing before a group of Rock ‘n’ Roll legends — lets face it, I’m nervous as hell. Aside from speaking at Dreamforce this year, I will also be opening the Dreampark once again, this time with Apex & the Limits (and special guest stars) and we will be performing our parodies — something we’ve done before sure, but this time we are playing with live instruments! Seeing as how we are all from different parts of the country — and world — when you hear us at the Dreampark, will be the first time that we’ve actually heard ourselves all together in this manner. It’s been an adventure getting this far and in a few short days it will finally become a reality.

So what am I looking forward to most? Opening the Dreampark, speaking at my session — these are all very cool things and I am both humbled and honored to be selected for doing either. What I’m most excited about however is getting to spend time interacting with the community that I’ve become so passionate about. Hanging out with my band family, my fellow devs and admins, and all of the amazing people in this community. I used to be a wallflower and to some extent I still am. Its VERY hard for me to strike up conversations with people I’ve never met, even when we have something in common. If I’m honest, I’m selfishly hoping that I’m somewhat recognizable now and that other will initiate said conversations just to make it easier, maybe I will wear the cowboy hat the whole time? Anyway regardless of who initiates what, I hope to meet more people from this awesome community this year, so if you wanna meet up at some point, find me on Twitter (it’s where I’m most active)! And with that, my DF16 experience begin very early Sunday morning so I’ve got some resting to do!

:wq!

Change is Good

Okay, I’d like to tell you this is more about my lightning stuff — and its not but I promise to get that stuff wrapped up, but this past month has been a whirlwind of change and all for the good, (albeit a bit stressful).

I have changed employers. Due to circumstances beyond control, my former employer had to close its doors. This was indeed for the better and will provide much less stress for the three of us. We all agreed it was the best option forward. However, I won’t lie — I was scared shitless. My MVP family was so great with numerous options and interviews but in the end I wound up convincing my old employer (of 10 years) to allow me to help them build a Salesforce practice. It took some dancing but everything fell into place….at the very last minute :)

That put a ton of stress on my family, and on myself. But patience won the day and I am now the Salesforce Practice Lead at Flexion, Inc.

While all of this stress was flying around, another little event that started as a simple tweet from fellow Apex & the Limits member Rachel Rogers to Marc Benioff himself, turned into a whirlwind of excitement, nervousness, and again — a bit of stress. We got asked to be the keynote opener at TrailheaDX in San Francisco. We had two weeks to put it all together and I must say, we couldn’t be happier! At one point shortly before we took the stage, we heard one of Marc’s staff say: “We currently have 383,000 live viewers” — lets just say I could have done well without ever knowing that little factoid!

We took the stage and couldn’t have been happier with the result. All the nerves seem to go away when you go out there and see your fellow community members cheering you on. It’s really why we do what we do, for the community, so thank you all so much for that. We look forward to being able to do this more as long as you’ll have us.

In closing — I just want to apologize to anyone that actually follows this blog for my recent absence. Now that I’ve safely landed and the preparation for our TrailheaDX performance is behind me, I hope to get back on a regular schedule and finish my Lightning components blog. In case I don’t get to that, be sure to come to Midwest Dreamin’ in July and catch the live version! And I want to thank my new/old employer Flexion, Inc for understanding the value in being part of this incredible community and giving me the chance to merge the two things I love most.

Thanks again!

:wq!

9904 — Is it an Illuminati Symbol? Or Just Good Fun?

Amber

Do you know this woman? She seems innocent enough, but stick with me my friends as I take you down the rabbit hole, behind the looking glass, make you swallow the red pill (or was it blue, I never remember). I’m about to blow your mind!

Today was Chris Duarte day and I can’t think of a more deserving person to have their very own day. However — something is amiss. Something is not quite what we thought it was. You may know Amber Boaz, or “Amber9904” as she likes to call herself but I’m on to her shenanigans — yes shenanigans! Suspicious, what is this “9904” that shrouded in such mystery? (To be honest I *still* don’t know that answer), BUT as you’ll soon see, today she pulled off a caper right underneath our very noses! She had to have had help from the illuminati…but that’s for a different day.

Let’s examine her twitter timeline from today shall we?

Never

Gonna

Give

You

Not that I need to continue — we know where this is heading!! But here we go nonetheless.

Up

What treachery? What debauchery is this? Did we actually just get Rick Rolled? Not once, but TWICE? Well Played Miss 9904, Well played, but we’re watching you now…we’re watching you.

P.S. I reached out to Miss 9904 for her thoughts on this scheme to which she replied: “No Comment!”

P.P.S. And I still have no idea what 9904 means…but I’m still thinking illuminati.

:wq!

Anyone Can Code

Last week I had the opportunity to help someone who was learning to code through one of the many different programs available to us, the Salesforce community. Whether you’re learning from the RAD Women program, Trailhead, one of the Salesforce provided classes, or simply teaching yourself, you will find at times that you hit a wall where things start to not make sense. Or maybe you start to fall a bit behind when the concepts start getting heavier.

One of the resounding things I hear from people that I’ve helped in this situation is actually rather alarming. What I’m hearing are people saying they feel dumb, or slow, or feeling like an idiot. Please, for the love of all that is good STOP thinking this way. What you are doing is hard, and its new and likely something you’ve never done before. Think of it like learning a new language or learning to play the piano. You wouldn’t sit down after a few short weeks and expect to crank out the Bach, Mozart, Beethoven symphonies would you? It’s all very much the same idea: practice, practice, practice.

I posted a quick Periscope about this over the weekend but seeing as how those things disappear after 24 hours, I thought perhaps instead of posting about my usual stuff, (don’t worry more lightning coming soon), that I’d just post these words of encouragement for those that may need it.

Just keep doing what you’re doing and remember: I’m always here to help.

:wq!

Trailhead on the Road

Today is the Salesforce World Tour Chicago event. Sadly, I’m here…writing this…whilst many of my colleagues are in Chicago, but I digress. I’m here for a purpose (besides billable hours). At this event, there is a flyer being circulated talking about this wonderful thing called “Trailhead on the Road” and while I didn’t create this thing, there are numerous questions being asked and the person who can answer those questions is nowhere near a laptop at the moment and is enjoying a sunny spring break in Florida. Therefore, hopefully you’ll allow me to fill that gap momentarily.

Like many great ideas…it was born whilst sitting in the airport coming down from another week at Dreamforce. For the background, you can read this, go ahead, I’ll wait…

All caught up? Good. As we were wrapping up that event, someone mentioned that we need to take this “on the road” which started another run of excitement. What would that look like? Where would we go? Could we even pull it off? The answer to those questions are: Pretty freakin’ awesome, wherever we can, dear God I hope so. :)

We are attempting to pull off our first “On the Road” event in Chicago on May 7th, 2016. The final content is still being produced but it will be lightning heavy on both the admin and dev sides. We will have several Salesforce.com MVPs in attendance, and will have two tracks. Each track may even go “off road” just a bit to assist in getting a bigger picture and a more “real world” example.

The event is not sponsored by any entity in particular so no sales pitches, just like minded devs and admins getting together to crack a few modules, and do some off-roading with Trailhead (and beyond).

If you’ll recall, I believe back in July of 2015 there was a “Trailhead Live” promotion all over the country. Its quite a bit like that but is being put on by members of the community.

Who knows where it will take us, but feel free to reach out to myself (in the comments and on twitter), or @JennyJBennett or the mastermind behind the whole deal: @chattyadmn for more information.

Until next time…

:wq!

Thinking About Lightning Application Architecture: Part 1

One of the things that really surprised me when I started poking at custom Lightning Components/Apps was the fact that I truly had to handle navigation from scratch. As a developer, we’re taught to never re-invent the wheel and to write code that is re-usable up front. Over the next few posts, I hope to discuss what I’ve found, what I’ve tried and what I’ve ultimately come up with when facing these challenges.

When I started out, I knew that navigation was something that I didn’t want to have to solve every time I set out to write an application. I knew I’d need a core group of components and events that would work in concert with one another and I knew that I’d have to keep these components generic enough that they could be included in any apps that I wrote. What I’ve come up with thus far appears to be working and I’ve done a demo for a couple different people and haven’t had any major “gotchas” pointed out to me yet. I’m still trying to get the ear of some other folks that I know are much more into Lightning than I am just to level set my expectations and find out if I’m really off in the weeds or not.

Before I get into the nitty-gritty, the back story here is that I had a customer approach me about creating a Visualforce page for a very complex custom object in their org. They wanted to be able to use the page in both the browser and on Salesforce1. If this were a simple object, this could have been simpler I imagine, however there are numerous dependent picklists that forced the original VF page to be spread out amongst several other clicks/refreshes, etc. This was not going to translate well to Salesforce1. Also, we wanted to avoid two different processes, one for mobile and one for the web. I made a couple of suggestions and one of them was to create a custom app that could be “created” via App Builder for use with Salesforce1 and an app that could be accessed via the web interface. (I’ve since done some playing with lightning out and prefer going that route for the web interface as it feels more native to the Salesforce experience).

However, budgeting for such an endeavor was a challenge because I’d never done anything like this before. I’ve been through the trailhead modules, taken a HOT at Dreamforce and toyed with it a bit on my own but only using rather simple examples. This was a chance to step back and tackle a “real world” scenario. I dove in far enough to realize, as some of my past blog posts have eluded to, that Lightning really is a “framework” in the most true sense of the word. There are just enough features there for you to work with, but you are left to your own devices to get things off the ground. Therefore, I started an example project in a dev org and this is what I’ll be going over in the coming posts.

Since #TahoeDreamin had just ended, and Apex & The Limits had been asked to travel to #SEDreamin — conferences were stuck on my mind. So my sample application was a very basic conference management application, its not fully baked and I plan to write more, but currently its just venue’s and conferences because…well consulting and billable hours take precedence. (Hey kids gotta eat man!)

The actual components are simple enough that I could use pre-built items for display, etc but I wanted to see how the system would behave with completely custom pages/forms, etc. since my clients’ application was not going to be able to take advantage of things like default page layout, record pages and what have you.

Rather than discuss the ins and outs of creating my custom objects, I’ll just tell you what I have and leave you to your devices to create them (or something similar) if you’d like to follow along. We have a Conference object and a Venue object. Each object has its own information, like addresses, start dates, end dates etc. Again since that’s not at all what this post is about, I don’t want to spend too much time here. Let’s get to thinking about the structure of the application since we are trying to be generic anyway.

Navigation:
I wanted to be able to navigate to a list of conferences or a list of venues so I knew I would need a basic component to display these links to me. I knew I would need custom components to display these lists and informational pages. What I didn’t know was how to navigate between the two. My intuition told me that selecting a record would need to fire some sort of event that I could handle and initialize/load the appropriate component. I had been googling and not found a standard, built-in navigation method. I did find e.force:navigateToSObject and other similar events, but those only work in Salesforce1 (according to the docs) & I needed this to work in the web interface as well. On top of that, I needed a component to fire that event anyway. I knew I needed to fire a custom event and it was looking like I would also need a component to fire it.

However, that’s only part of the problem. Even if I managed to fire this custom event, how were people swapping components in and out. And then I came across this. Basically, I needed to create a container component that would house my custom components and swap them in and out of there.

The last piece I needed was some generic code to be able to handle my custom event, get the name of the component I intend to load and have my container component’s controller load that component. I created a “Base Component” that will be my container and a matching controller that will initialize my entire app (based on a parameter, but more on that later) and also handle my “navigation” by swapping out custom components as signified by my custom event. That looks something like this (I’m using the Lightning Design System to style things):

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" controller="BaseComponentController">
	
	<aura:attribute name="appName" type="String" />
	<aura:attribute name="activeComponent" type="String" />

	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
	<aura:handler event="c:NavigateToComponent" action="{!c.loadComponent}" />

	<div class="slds" style="padding: 10px;">
		{!v.body}
	</div>

</aura:component>

And my Base Component’s controller (NOTE: much of this code should be moved to the helper class, I just haven’t gotten there yet):

({
    doInit : function(component, event, helper) {
            //ignore this bit for now, more on that later
            var action = component.get("c.getDefaultComponent");
            action.setParams({
            	"appName" : component.get("v.appName")
            });

            action.setCallback(this, function(response) {
            	var state = response.getState();
            	if(state === "SUCCESS") {
            		//load new component
            		var defaultCmp = response.getReturnValue();
            		$A.createComponent(
            			defaultCmp,
            			{},
            			function(newComponent) {
            				component.set("v.body", newComponent);
            			}
            		)
            	}
            });

            $A.enqueueAction(action);
    },

    //this is the custom swapping of components piece...
    loadComponent : function(component, event, helper) {
        var newCmp = event.getParam("targetCmp");
        var attrs = event.getParam("attributeList");

        $A.createComponent(
			newCmp,
			attrs,
			function(newComponent) {
				component.set("v.body", newComponent);
			}
		)
    }
})

The “magic” here lies in my controller’s loadComponent function. You will notice that my Base Component is handling a custom event called “navigateToComponent” — this event gets fired by another custom component (we’ll discuss that in my follow up post), my base component will handle that event and inspect it for the name of the component I’d like to load as well as any custom attributes my new component will need, such as the ID of an object I’m trying to load into that component. This function calls $A.createComponent which loads an instance of my component, and swap it into place where my Base Component has {!v.body} specified.

So now “theoretically” (this is all just my observations, but it is indeed working) I can fire my custom event, pass in the name of any component and its attributes and load it without my Base Component having to know anything about the component it is loading nor its data. If I use this base component in all my future apps (along with my custom event), navigation is solved for me.

That’s plenty of writing for me, and reading for you at the moment I think. Hopefully next week, I’ll have the custom event queued up for you :)

:wq!