Tuesday, December 22, 2015

Introducing the newest Trailhead Peak: The Apex Integration Services module



As an integration architect, I spend a substantial amount of time with clients discussing how to integrate with their systems external to Salesforce.  Most times, fortunately, clients have a pre-existing system with a set of available APIs that are exposed either as RESTful or SOAP APIs.

A prime example of this, is the work I helped with on a hi-fidelity music service.  In order to get licensing information, track and album details, and other information, we made several RESTful calls out to a music content provider.  Additionally, we used SOAP services to handle payment processing, tax calculations, and address verification.

In order to work with these external systems, Salesforce provides mechanisms like WSDL2Apex, JSON and HttpRequest utilities that developers can utilize in order to interact with external systems.  If you're not familiar with how this works yet, I strongly urge you to check out the newest Trailhead module "Apex Integration Services".

The new module, which can be found here: https://developer.salesforce.com/trailhead/module/apex_integration_services, contains a lot of useful information on how to develop and test callouts to both REST and SOAP services.  The latter part is key, because the module requires you to use mock callout classes in order to unit test your callouts.  In days past, developers would skip over their callout unit tests using the dreaded if check of !Test.isRunningTest().  However, I'm glad that the module teaches new developers on how to properly test their callouts.

I have to be honest here though, and ask that when you walk through the challenges for the Apex Integration Services module, that you take a bit of heed.  For instance, you might notice that the check for your REST challenge might fail if you don't use this exact line when constructing the HTTP instance:

Http http = new Http();

One boards poster found the following line caused in issue with the rules engine when checking their hallenge:

Http h = new Http();

Also, when you start the SOAP services module, be very careful on how you import the WSDL file.  After you click the "Import WSDL" button, you need to rename the Apex class from the defaulted "parksServices" text to "ParkService".  The case sensitivity along with the correct name is vital to ensuring your challenge is completed successfully.

With those caveats in mind though, the instructions are laid out well and once you pass the Apex Integration Services, you'll have a better understanding of how to integrate Salesforce with external systems.

Happy Trails!



Saturday, September 26, 2015

The Neverending Trail



The Neverending Trail

Before we get started with this blog post, let's go over a few facts:
  1. I watched The Neverending Story no less than 1.2 million times throughout daycare and elementary school.  Also fitting that I never finished watching the movie.  Want to go ride a bike?
  2. There are currently 65 badges on Trailhead!  Sixty-Five!  Well, 66 if you include the April Fools edition Catter badge.
  3. I'm a little addicted to Trailhead and went on a binge to get the 20 or so recent badges.  #BingeBadging
  4. I am officially dubbing Trailhead "The Neverending Trail".  With 66 badges currently and many more likely to come, it really is a trail of never-ending, amazing hands on Salesforce experience.

The "Neverending Trail" may seem a bit daunting term, but I mean it endearingly.  As a commoner on the Developer Boards, one of the easiest questions to answer is "How do I learn about "X" on Salesforce without having any project experience?"  The answer is always to head on over to http://developer.force.com/trailhead and check out all of the amazing hands on training excercises.  

The endless influx of training content is not only a savior for answering questions around the Salesforce community, but the amount of knowledge I walk away with from each module is so rewarding.  Yes, the badges, points, and other gamfication aspects are addictive, but even more so is the breadth of knowledge that you walk away with after completing those hand on training exercises known as Trailhead modules.  

With the 20+ badges released the week prior to Dreamforce, there is literally something for everyone on Trailhead. Are you a new Admin? If so brush up on the Admin Trail.  Are you looking to learn about the new Lightning Experience?  If so, throw some confetti and hop on one of the Lightning Experience trails.  Are you a developer looking to learn more about Heroku Connect?  There's a project for that.  

Oh, by the way, there's three modules / badges on Wave, a Salesforce Analytics platform you may have heard about.  Even if you aren't a self-proclaimed analytics junkie, you NEED to check out the Wave modules.  They are far and above my favorite Trailhead modules to date.  After completing the Wave modules, I felt like Keannu/Neo in the Matrix:


So again, do you have all 65 available Trailhead badges?  If not, what are you waiting for?  Head on over to http://developer.force.com/trailhead and start down your own trail(s) today!  

Thursday, September 24, 2015

CSS Animations and the Lightning Design System

I've had the fortune of tinkering with Lightning Components and in particular using them with the Lightning Design System lately.  If you're unfamiliar with the Lightning Design System, I strongly urge you to head over to http://www.lightningdesignsystem.com and read up on it now.

There are several goodies and easter eggs in the Lightning Design System, including the "Visibility" utilities (https://www.lightningdesignsystem.com/components/utilities/visibility).  The visibility utilities allow you to show and hide SLDS elements within your application, including in your Lightning Components.

In Lightning Components, you can easily utilize JavaScript controller logic to toggle CSS, utilizing a method like below:

({
hideMe : function(component, event) {
var el = component.find('myAuraIdGoesHere');
         $A.util.toggleClass(el,'slds-transition-hide');
}
})

Combining the toggleClass method along with the slds-transition-hide class from the Lightning Design System, allows you to hide (and show) elements when some event happens within your lightning component, such as clicking on a close button or perhaps swiping an element left or right in a tindr-like fashion.

The slds-transition-hide class is excellent. However, it has two major issues right out of the gate.

  1. The opacity is set from 0 to 1 immediately, and can be "jarring" to the user.
  2. The opaque / hidden element still takes up space on the screen if it's a block layout, such as a div.
Enter CSS and Styling.  The Visibility documentation on the Lightning Design System hints that you should use a transition property to control transition and animation of the element you're hiding: 

"Note: To control the timing of the transition, add an additional transition property to control the opacity change."
The transition property is a CSS style you can give an element to control a limited set of properties such as the opacity and the height of an element.  Unfortunately, the display property is one that you cannot transition on.  In other words, I can't transition from display: inline-block to display: none.  So, to get around the 2nd limitation of the slds-transition-hide styling, we'll have to utilize the height of our element and "shrink" the element over a duration of time.  To do this, I extended two of the classes I'm using in the Lightning Design System by modifying the "Style" of my Lightning Component Bundle:

.THIS.slds-media{
max-height: 250px;
.THIS.slds-transition-hide{
opacity: 0;
height: auto;
max-height: 0;
transition: opacity 2s linear, max-height 2s linear;
}
First, I had to guess the max-height of my div.  The div height is variable, but it *should* never exceed a height of 250px.  Without setting the max height of the visible div, the transition has nothing to compare to the new max-height, so you get a very jarring and immediate transition to 0px if that's the case.  Try it for yourself and you'll see what I mean.

The second class gets toggled when a close button is clicked in my lightning component (from the first snippet above).  Using the height, max-height, and transition properties and applying them to the LDS's slds-transition-hide class, we will now get a fairly smooth transition of both opacity and height over a duration of 2s.

So now that I've showed you both the component bundle's controller and the component bundle's style, let's take a peek at what the component itself looks like:

<aura:component > <aura:attribute name="someType" type="SomeTypeGoesHere" description="Some Description" />     <ltng:require styles="/resource/LightningDesignSystem/assets/styles/salesforce-lightning-design-system-vf.css" />         <div class="slds-media slds-tile slds-hint-parent" aura:id="myElementId">           <div class="slds-media__figure">               <img class="img" src="{!v.someVar.Image_Url__c}"/>           </div>           <div class="slds-media__body">             <div class="slds-grid slds-grid--align-spread slds-has-flexi-truncate">               <p class="slds-tile__title slds-truncate"><a href="#">{!v.someVar.Name}</a></p>               <button onclick="{!c.hideMe}" class="slds-button slds-button--icon-border-filled slds-button--icon-border-small slds-shrink-none">                 <c:svgIcon class="slds-button__icon slds-button__icon--hint slds-button__icon--small" svgPath="utility-sprite/svg/symbols.svg#close"/>               </button>             </div>             <div class="slds-tile__detail">               <dl class="dl--horizontal slds-text-body--small">                 <dt class="slds-dl--horizontal__label">                   <p class="slds-truncate">Label:</p>                 </dt>                 <dd class="slds-dl--horizontal__detail slds-tile__meta">                   <p class="slds-truncate">                       {!v.someVar.Value1__c}                   </p>                 </dd>                 <dt class="slds-dl--horizontal__label">                   <p class="slds-truncate">Label2:</p>                 </dt>                 <dd class="slds-dl--horizontal__detail slds-tile__meta">                     <p class="slds-truncate">{!v.someVar.Value2__c}</p>                 </dd>                 <dt class="slds-dl--horizontal__label">                   <p class="slds-truncate">Label3:</p>                 </dt>                 <dd class="slds-dl--horizontal__detail slds-tile__meta">                     <p class="slds-truncate">                         <ui:outputCurrency value="{!v.someVar.Value3__c}" />                     </p>                 </dd>               </dl>             </div>           </div>         </div> </aura:component>

In the component above, when you click on the close icon, it calls the hideMe method in the controller, which toggles the CSS class starts the CSS transition.  Putting it all together, here's what the component looks like in action:



And there you have it, a way to utilize the Lightning Design System, Lightning Components, and CSS Transitions / Animations.  Granted, my solution may not be the best solution.  If you have a better solution than the one above, feel free to comment on this post and let me know.

Monday, August 10, 2015

Thirty Six Badgers ready for the Taking. Conquer the Trail today!

Check that out, it's been exactly 1 year since my last post on here.  For the few that will see this particular post, I typically post on my company's blog here: http://www.edlconsulting.com/author/james-loghry/

That being said, one of my favorite topics to blog on lately has been Trailhead (https://developer.salesforce.com/trailhead/).  For a quick introduction, trailhead is an amazing platform for hands on experience and training with all things Salesforce.

  • Starting to study for your Administrator, Developer, Advanced Developer, Consultant certifications? See Trailhead.
  • Curious about learning hybrid or mobile development and Salesforce? See Trailhead.
  • Have been working on Lightning components, but can't remember how to handle events in the component bundle? See Trailhead.
There are currently 36 badges available for a variety of trails, modules, and projects.  I have 37 of them (Catter was available as a limited April Fools day version and no longer available).  Badges themselves are addicting, but honestly it's the knowledge within the modules and projects that keeps bringing me back.

As a personal anecdote, I was working on a project utilizing the Lightning Communities pilot, but was having a hard time grasping the new event-centric infrastructure that is Lightning components.  Going back through the Lightning related modules and projects helped shed more light on the components and helped me make sense of the framework.
Of the 7 trails, 30 badges, and 6 projects I will say the following:
  • The new DF15 badge and Salesforce Basics modules are the easiest to get started with.
  • The new event monitoring badge is great.
  • Be sure to explore the "Projects" link, as it is easy to miss. 
  • Some of the projects can take quite a while (as in hours) to complete, so plan accordingly.
  • I can't wait for even moar badge(r)s!
So what are you waiting for?  Drive your browser to the Trailhead (https://developer.salesforce.com/trailhead/) and start earning your badges and conquering those trails today!