Wednesday 17 January 2018

Get developing advanced UX fast and free with Salesforce and Skuid

I always appreciate it when a technology provider offers a free entry path for developers to get their hands on their product, to have a play, poke around and see what it can do. I can't think of a better marketing tool than letting the people who will be responsible for deploying a product familiarise themselves with it first, and if it's any good - potentially become advocates and inadvertent salespeople themselves.

Skuid and Salesforce are brilliant example of this. If you want to try your hand at developing on the Salesforce platform, all it takes in 3 minutes and an e-mail address. If you then want to try your hand at building some of the most glamorous and productive user interfaces using Skuid, you can be equally up and running within the time it takes to boil a kettle too.

Here is my quick low down on how to do that.

First, get yourself a Salesforce Developer Edition. Navigate your browser to

https://developer.salesforce.com/signup

and fill in the easy form. Remember the beauty of Salesforce Usernames is that they have to be in the form of an e-mail address; but not an actual e-mail address. They also have to be unique across all of Salesforce, so I normally go for a clever little intuitive trick like "simon.lawrence@myfirstskuid.com" - pretty guaranteed to be unique, memorable, and in the form of an e-mail.




So, now you have a Salesforce instance so you just need to get Skuid in there and working. For this get yourself another tab (tabs are fun) and navigate to the AppExchange page for Skuid: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000009wyDjEAI

Click






At the bottom of the page and install Skuid in a Production Org. Make sure you are not logged into any other Salesforce orgs! There is a confirmation page showing where it will be installed, and sometimes you are forced to re-authenticate to be sure. Install it for all users (probably) and wait a few minutes for it to chun over (this is the moment to boil that kettle).

It might tell you it will e-mail you when it's finished, or it might just take you to your Installed Packages, depending on how fast the Cloud is feeling.

Either way, just sip your tea/coffee/vodka and and in a few minutes Skuid will be there.

Once it's installed, click on the App Manager icon (loads of little dots) and then select "Skuid Central" from your "All Items" list.



You are now up and running in Skuid! You will see the "Lets Get Started" page and the black banner that will soon become your best friend.




But that's not quite it!

You only have a 30 day trial at the moment, and you are not going to want to lose all your hard Skuiding (* not an official verb) in a months time... so...

...here's my favorite bit, if you head to the Skuid sign up page at https://www.skuid.com/free-trial/, there is a link at the bottom to turn your 30 day trial into an unlimited, full installation to play in forever.


Click that link and fill in the form (change the radio button to Salesforce when it asks you what type of licence you want) - this will contact Skuid, and very shortly someone will flip the switch to make your Skuid licence endless and all-powerful (you don't need to wait for that though).

FYI your OrgId is shown on the "Company Information" page - available from the Setup menu:




So you are away! Get back over to that Salesforce tab and start writing Bespoke UX at Blazing Speed!

Friday 12 May 2017

TrailheaDX here we come!

There is a new Salesforce conference event on the horizon, and I think it's going to be a good one!

I missed Dreamforce 2016, through my own misadventure (I literally got married the weekend before) - and I also missed Dreamforce 2015 - because I had attended the previous three years, and Desynit had a swathe of excited new developers so it only seemed fair to let them attend whilst I held the fort back here in Bristol. I thought with a two-year hiatus, if I worked real hard, and was real nice to the management - my application for Dreamforce 2017 would be met with open arms....

Imagine my horror then; when Desynit announced conference attendees for the year, they told me I wouldn't be attending Dreamforce 2017 either! Three swings and three misses, what had I done wrong?!

Well - what had I done RIGHT - because Desynit then announced they weren't going to send me to Dreamforce this year, they are going to send me to TrailheaDX instead!


My fellow Salesforce developer Dorian Sutton and I will be jetting off to San Francisco at the end of June to take part in what I personally believe could be a turning point in the "Computer Science Conference" world.

Previously there have been two types of IT Conference - there is the Dreamforce style - which let's be honest is a flashy party full of salespeople and free branded pens (which break before you get them home). It is a fun party, and it's always nice to meet so many people and see so many sessions - but to the development world it's also a little like being an exhibit at a zoo; and also typically pretty overwhelming.

On the other side of the coin, there are IT conferences (typically held in educational institutions) where the loudest noise you will hear for 3 days is someone dropping a tea spoon at one of the coffee stations. Back-to-back sessions (often led by sponsored bigCo experts) make sure no-one is forced to suffer the indignity of having to talk to a stranger for any length of time and half the attendees are actually just there to get away from their colleagues and cubicles - and are back in their hotel rooms by 17:29 each day.

Enter TrailheaDX.

TrailheaDX - to me - looks like an incredibly exciting opportunity to finally have a technically oriented conference environment, without too much of the "whooping" and t-shirt cannon hype, but still actually in Technicolour™, with some life and vibrancy to it.

You know it's going to be good, because the actual Salesforce platform developers and engineers will be there, talking to people and leading sessions.

If you look at the session list it is absolutely cutting edge. Advanced Lightning Components, Einstein the DX CLI - this isn't just people revamping a presentation they gave 6 months ago (and 6 months before that); it's new and exciting, and for once - the Safe Harbour statement might actually mean something to me!

The CLI

This is the biggy for me, at Desynit we have spent hour and hours, over months and months trying to work out, and improve our version control, release processes, disaster recovery, forward-working enviroments and everything that every over branch of programming has at least some options for.

We have Bitbucket, and scripts, and can often be found begging each other to try to follow the convoluted processes we have that basically make every change request cost sweat and blood. The DX CLI promises to solve all these problems for us and make our lives bliss (remember that safe harbour statement I mentioned earlier?!)

But we are seriously looking forward to this, the whole team will be waiting with baited breath for our return from TrailheaDX to report back what the upcoming changes will be for Metadata control and Git integration to Salesforce.


So if you are going to be there.... get in touch with me on Twitter, and perhaps we can meet up for that awkward coffee that I'm hoping I actually won't have to do; but more importantly, we can retweet each others experiences, which is far more interesting anyway.








Monday 16 January 2017

Take the lead - in your local Developer community

Related Reading: The Salesforce Developer Career eBook

Ever wonder who those super-stars are who run one of the hundreds of Developer User Groups around the world? Do you see the DUG Leaders getting shout-outs in Salesforce Podcasts, keynotes and blogs and think 'who are these heroes, and where did they come from?' ...

Well the answer is, they are actually most likely folks just like you; and therefore you can be one too!



Five years ago, the Directors at Desynit were talking to Chris Lewis and myself about some great times they used to have in London when they ran an occasional knees-up for the CA Plex developer community that they called Plex in the City. They just picked and broadcast a date and a pub, put it on some Plex forums, and developers turned up and had a great time. They made connections 14+ years ago that they still keep now, and every now and then the phone still rings at Desynit from someone looking for the "Plex development team" here..

This led Chris and I to decide to start “Force by Forcewest” a developer user group for Force.com Developers in the Southwest of England.


So we sent some e-mails, created a Facebook and Twitter page, and made a tiny flag which we stuck in an upside down plastic cup. When the date rolled around the two of us went nervously to the pub at the arranged time - and waited...

..and you know what; out of the dark, developers turned up!

We had a great time swapping stories, debating and drinking a few beers, and we agreed to do it again. I met some people on that very first meetup in 2011 whom I am still friends with today. More importantly, it went on to me discovering the vast and supportive Salesforce community - for which I now hope I am a useful part!

It was at Dreamforce 2012 I saw a session by Andy Boettcher titled “How to run a Salesforce developer user group” - I thought I’d struck gold, a kindred spirit! I was first in line for the session, and so imagine my surprise when he introduced both April Nassi - head of Developer Relations at Salesforce, and the fact that already there were already dozens of groups all over the country. After the session I spoke to Andy and April, and she set me up with all the information I needed to run a local Salesforce developer user group… both the Meetup group page, the financial support Salesforce can offer for hiring meeting facilities and food/drink and within a couple of weeks, a great big box of t-shirts, caps, books and even a Salesforce iPod to use as a prize or giveaway!

Within 6 months we were up and running, a new official Salesforce DUG for Bristol - and I was suddenly one of those heroes I thought the world of!

If you have even the slightest desire to get involved in your local developer community, you have a couple of options: find your nearest one and go along, or if there isn’t one near enough be your own local hero and start it up! If you are worried about the work load - firstly, it’s really not that hard(!) and secondly, you will probably find within a meetup or two that there are a couple of other people who will be keen to get involved and help organise events with you.

To find your nearby group head over to https://www.meetup.com/topics/salesforce/ and check out the map.

Have a browse over the DUG FAQs on the Salesforce developer blog

Get in touch with @Salesforcedevs on Twitter where you will get answers to everything you need to know! The DUG Leaders have their own amazing leadership team directly within Salesforce, we have a Slack channel, a Mobilize feed, and a DUG leadership group, which has occasional worldwide conference calls for sharing ideas - getting updates from Salesforce and feeding back on our experience running the groups. It’s a great bunch of people to be a part of.

Tuesday 2 August 2016

Discover new opportunities in IT, South Wales style!

August 13th 2016 sees the first ever Surf Force event, held in Aberavon, near Cardiff.

But what is Surf Force?

Surf Force is the brain child of Desynit's very own Shaun Holmes. a once award winning surfer, turned Salesforce expert. Shaun wants to combine his passion for this fun oceanic hobby with opening the doors for new opportunities in the IT sector in Wales, with one of the most innovative and welcoming computer technologies, Salesforce.


Why should you attend this totally free event?

If you wish to, arriving a little earlier will get you a full on breakfast, and a couple of hours of free surfing lessons with  a professional surfing school before the days main events...

..If you aren't so keen on wrestling a shark, arriving at 12:00 gets you free access to up to 7 hours of informative speaker sessions, hands on experience and great opportunities to meet and network with some leading voices and personalities in the Salesforce development, employment and training sectors.

(You'll also get a free t-shirt, free lunch, and some drinks at the Happy Hour that follows the main speakers of the day!)

If you are thinking of finding new work in the IT industry, or expanding your existing horizons in an existing office/administrative role, this is a brilliant opportunity to see how easy it can be to make waves in the Salesforce world!


(Aberavon Leisure & Fitness Centre – Princess Margaret Way Aberavon Seafront, Aberavon, SA12 6QW)

With speaking sessions from Entrepreneur Anna Bastek and Technology Super-Innovator Dave Carroll, alongside 5 other brilliant presenters, there is a lot to take away from this day.

Meeting with the chief sponsors, such as Mason Frank and Impact IT Solutions at their expo stands will also give you a chance to see the great products, services and software they provide.

All you need to do is sign up now on Eventbrite, and it's next stop - Surf City! 

Friday 19 February 2016

Navigate the Salesforce Advantage

Arrr. Me hearties. Tis time for another Trailhead module review... this time, no battleships, but PIRATE ships, as we Navigate our way through the Salesforce Advantage Sea...


Learn about the key differentiators that drive our success: our core values, innovative technology, and vibrant ecosystem.


So go throw on yer best sailing hat, grab yer cutless and join me on a sailing adventure across all that this great module has to offer!

This here module is a little different to t'others ye might have done in the past.. it's not got the technicals, ye won't be needin' yer fiddly code or clicks, but what you will be gainin' is a mighty haul of treasured information on why Salesforce is the greatest ship to float on that there Internet, both for yourself, and yer piratin' business.

B'fore ye gets to the wheel house though, yer gotta start down scrubbing barnacles off the belly of the boat.. Module 1 covers the 4 cornerstone philosophies of why Salesforce be the best in the market for not only Cloud CRM.. but every part of yer business. Don't fret too hard on the quiz, no-one is getting hung and drawn in this exam, it's as easy as taking candy from a French merchant ship. There be a truly terrifying picture of Marc Benioff from 1999 in there though, so brace yerself for that.

Once yer've snagged yerself a ships wheel for your efforts... why not boast to all your buccaneer buddies over in LinkedIn, with the SSO link. All true pirates use LinkedIn you know.

Module 2 be on all the bits of the great ship Salesforce from the Masts (lets say that's Sales cloud) to the decking (the AppExchange maybe?) it all be there ready and available for you to sale your way to success. A good pirate knows his way around his ship, and this module gives you an idea of how bigger boat you've got. Speaking of size, if ye get yer britches in a twist on the exam in this module... the answers are the longest, most expansive ones ;)

Arrrgghhh!! Whats this?! Does a storm be a brewin'?! Oh... no... it's just the Clouds coming in, the second half of this module explains why not having to worry about all that computer hardware, servers, backup, multiple-OS configuration is so amazing.. Salesforce is one ship that's NOT afraid of a bit of cloudy weather, in fact, it was one of the pioneers of Sailing on the cloud, and will continue to be so for some time.

Answer a couple more questions to get the next bit of yer ship together, the prop, now we're going places!

The next module says it will take 5 minutes, and that's only if you decide to sit and ponder the quote from Parker Harris for 2 minutes... it's a bit of a doozy to be sure, but that's because it's the simplest concept ever - how to trust the Cloud. When you get to the quiz on this module... see if you can work out why I got question 2 wrong:


It's harder than ye be believin'

In learning the value of multitennancy we find out what having all our pirate buddies about is about, and why its actually quite a cool thing. I wish when I lived on my own I had a door man, and if I'd lived in the cloud I could have done.

The next chapter in this module is on MetaData, so we be startin' to get a little more technical..  but there is really only one thing you need to know about this module is that at 1:24 in the video.. a pig uses Salesforce1. I think my next Developer Edition exploration will have to be a farm, I've never done that before! (oh, we're supposed to be pirates aren't we... ahem.. arrrhhhhh). The key to Davey Jones' locker here is that Metadata is everything you have defined in the cloud, and that it is yours, it is safe and secure, but it is based on the same powerful platform that some of the biggest and most successful businesses use.

For a developer style ship mate, this next module is an interesting one, I feel like it gives the world a good impression of what we do, but no-one really likes seeing their job described as being "5 times faster" than usual... I can almost hear my deadlines screeching in around me ;) keep your cannons loaded though and you'll be able to keep those milestones at bay.

I'll also be honest to the pirates code, and say that question three is a tricky one for me, because I freaking love coding. But I kept it together and fired the canon ball to the back of the net for another 100 points, and another badge on my pantaloons.

The final module on this vast voyage starts with Community. This is a personal favourite of mine, as I am almost entirely submerged in what is really a global community of Salesforce developers and experts. As I organise the my local Developer User Group here in Bristol (UK), and attend our User Group, as well as other groups around the country.. I have also had the pleasure of attending Dreamforce in San Francisco, and the MVP summit in the same city.

I have genuinely got to a point now, where it is as easy and quick for me to pop a question on the Internet to get help with a Salesforce question as it is to turn to the people in the room with me.

The final chapter, err.... Meet an MVP?! Well, Hello! If you have made it this far into one of my blog posts, I already probably consider you a closer ship-mate than you'd imagine. Here be my pirate calling card.. get in touch whenever you need!



Captain Simon Lawrence





If you need any other MVPs in the Bristol area, feel free to pop a tweet to my colleagues @adtennant or @jenny_bamber, or indeed dig up Chris Lewis, Matthew Morris or Simon Goodyear.

So that be the journey completed, get those badges on your profile! You're half way to having your own Pirate ship...



Monday 15 February 2016

The way of the Lightning Component

This is a quick walk through of how I wrote my first Lightning Component in Salesforce, to give myself a feel for the process, and develop my own skills in this up and coming technology.

But what to do? I didn't want to actually produce a piece of serious functionality, thats what I do at work all week anyway, but I also didn't want to create a piece of HTML that wrote "Hello World!" in a totally separate and useless app.... and then I had a thought, why don't I write an integration to the Internet Chuck Norris Database, providing a contacts name, and then display a "Chuck Norris" style quote on the contact page...? 



(For those of you who didn't know, the ICNDB provides quotes about Hollywoods most bad ass actor, Chuck Norris, and it of course also provides a RESTful API - to which you can provide alternative first and last names, to receive some JSON with a quote tailored to that person)

So this was a fairly simple example, but it included a web call out, which is always interesting, and also meant I needed to embed the component on a standard view page, and pass information about that record to the component. I felt this was just the right amount of complexity. 

First off then: The component

It seemed logical to start with the component. I did all this work through the Developer Console, so some boiler plate was put in place with me as soon as I selected to build a new Lightning Component from the File menu.

All I needed to do was put some HTML in the aura:component tag, and putting some activity code into the client controller. So some gotchas - you can't make a web callout from the client controller in Javascript, logical I suppose, it is a bit wild - security wise; and a performance liability. I also had trouble getting the function to run from the "init" tag, so I put it behind a button for a while, but eventually it just started working under Init as well. I think perhaps I was just impatient!

ContactChucker.cmp

<aura:component controller="ChuckController" implements="force:appHostable,flexipage:availableForAllPageTypes">
    <aura:attribute name="firstN" type="string" default="Chuck" />
    <aura:attribute name="secondN" type="string" default="Norris" />
    <aura:handler name="init" value="{!this}" action="{!c.requestQuote}" />
    <ui:outputText value="{!v.quote}"/>
</aura:component>

In here we have a couple attributes, that bind to the data sent in from the Contact page (details below in the Visualforce section) and then an Aura:handler instructed to execute on init and the output text from the standard UI library for the quote, quite simple in the end.

The "Implements" section uses some standard Component libraries to tell Salesforce this component needs to work on all pages (Visualforce, standard view etc.etc.) and is "Hostable" - which is also something to do with placing it on Visualforce.

The action in the init tag calls the component method requestQuote - as described here:

ContactChuckerController.js

({
 requestQuote : function(component, event, helper) {
        var initAction = component.get("c.getChucked");
        initAction.setParams({ firstN : component.get("v.firstN"), secondN: component.get("v.secondN") });
        initAction.setCallback(this,function(response){
                if (response.getState() === "SUCCESS"){
                    component.set("v.quote", response.getReturnValue());
                }
            });
        $A.enqueueAction(initAction);
    }
})

Just one simple function, which sets up a method call to our Apex controller called getChucked. I think all methods coming from the Apex need to start "get", and I don't know why the c. prefix is required. This had to be like this though because I couldn't call ICNDB from Javascript, so I use standard javascript to pull off an Asynchronous callout,  I can set the parameters by GETTING the values from the attributes on the page, and passing them in with "setParams".. and then in the callback function I use the Component.set method to update the quote in the UI output text element.

Once I had this component ready, I needed to house it in a Lightning Application, which I did so by making a new Application from the developer console, and simply entering:

ContactChuckerApp.app

<aura:application access="GLOBAL" extends="ltng:outApp" >
    <aura:dependency resource="c:ContactChucker" />
</aura:application>

Here I just needed to tell Salesforce the app was available to anything that wanted it, and that it would be output on Visualforce pages (the outApp base controller). That is really it.. In this form, the preview button comes up blank, because the app doesn't actually make a component, just depends on it... but to test it, instead of that being a dependancy, you can actually just include the c:contactchucker tag to initiate the component right in the app.

A little Apex

So I now had a component, but it was trying to use a controller to make a call out that didn't exist.. so we better fix that. Here is the simple controller method to make the call out, as an @AuraEnabled method, and some clever innerclasses to facilitate the JSON deserialiser.

ChuckController.apx

public class ChuckController {


    @testVisible
    private class JsonJoke {
        public String type { get;set; }
        public JokeValue value { get;set; }   
    }


    @testVisible
    private class JokeValue {
        public String joke { get;set; }
    }


    @AuraEnabled
    public static String getChucked(String firstN, String secondN) {
     HttpRequest req = new HttpRequest();
     req.setEndpoint('http://api.icndb.com/jokes/random?firstName=' + firstN + '&lastName=' + secondN);
     req.setMethod('GET');
     Http http = new Http();
     HTTPResponse res = http.send(req);
     JsonJoke jsjk = (JsonJoke)JSON.deserialize(res.getBody(), JsonJoke.class);
     return jsjk.value.joke;
   }
    
}

I hear what you are thinking though, with Apex, we need tests to be able to package or promote this work. Well, don't freak out, there is a really simple test to assert this behaviour that utilises the Apex testing MockHttp library:

ChuckControllerTest.apx

@isTest
global class ChuckControllerTest {


    global class NeverMockChuckService implements HttpCalloutMock {
        global HTTPResponse respond(HTTPRequest req) {
            HTTPResponse res = new HTTPResponse();
            ChuckController.JokeValue jv = new ChuckController.JokeValue();
            jv.joke = 'MS Dynamics';
            ChuckController.JsonJoke jj = new ChuckController.JsonJoke();
            jj.type = 'joke';
            jj.value = jv;
            res.setBody(JSON.serialize(jj));
            return res;
        }
    }


    @isTest
    public static void auraComponent_HttpMocked_ReturnsResult() {
        Test.setMock(HttpCalloutMock.class, new NeverMockChuckService());
        String quote = ChuckController.getChucked('Simon','Lawrence');
        
        System.assertEquals('MS Dynamics', quote);
    }
    
}

There's 100% coverage in your pocket right there.

We have a bunch of code then, and basically a working component, but we have a little more to do to get it on the page and operating. First we need to get it into a chunk of Visualforce, which means two things: Making a Visualforce page (that uses the Contact controller, so it can be put on the details page) that actually renders the app and component, and then passing the Contacts name down into the app so it can be sent to ICNDB... This is what the Visualforce page ended up being:

ChuckPage.vfp

<apex:page standardController="Contact">
    <apex:includeLightning />
    <div id="chuckLine" />
    <script>
        $Lightning.use("c:ContactChuckerApp", function() {
          $Lightning.createComponent("c:ContactChucker",
          { firstN: "{!Contact.firstName}",
            secondN: "{!Contact.lastName}" },
          "chuckLine",
          function(cmp) {}
          );
        });
    </script>
</apex:page>

This is a standard (and apparently famous) snippet for embedding a Lightning Component on a Visualforce page. Include the Javascript, set up an empty div container, and then use that Script tag to setup an instance of your app, and then inject the dependant component... (don't get too bogged down in namespaces here, it's all just "c" it turns out). The second parameter of the createComponent is a Javascript object that is bound to the attributes of the Component above.. gotcha: do not use reserved words or field names here, like 'contactName' as an attribute, or it will never work! I spent ages wondering why I couldn't pass the contact name in, until I switched over to firstN and lastN as my attributes, contactName simply would not be set.

The last two things to do now then is to put this piece of Visualforce on the standard Contact page layout, and ... have you realised the last thing? You need to make the icndb.com domain a REMOTE SITE in remote site settings, or Salesforce won't be allowed to talk to it.

That is it though! you now have your own bad-ass Chuck Norris quotes about your Contacts in Salesforce, curtesy of Lightning Components. Here are some personal favourites...





Friday 18 December 2015

Get your smarts on over Advanced Salesforce formulae

Something I have blogged and tweeted about a couple of times in the past is writing quality, advanced formula fields. Having a good grasp of Salesforce formulae reaches beyond just formula fields though, as we encounter this mark up in Workflows, Approvals, Validations rules and numerous other areas of the declarative side of the platform.

Badly written formulae can quickly start to stack up in your org (and I mean that literally - if you know how Formula dependencies are inter-compiled) so why don't you stop the rot before it begins with a new exciting Trailhead module... Introducing:

 


Trailhead reckons this module will take about 2 hrs 30 mins and we know from past experience those estimates are pretty accurate, but this module is nicely broken up into 7 chunks, none more than 30 minutes, so again, as we know from before we can easily fit these bitesize chunks into our regular, busy days. I'm actually on holiday today, and so I am going to secretly work through these modules as Laura fusses about the house doing Christmassy things.

So, First

Laura: Shopping on "notonthehighstreet.com" for a novelty cushion as a Christmas present

Simon: Using Basic Logic in Checkbox Formulas

The first thing I had to overcome is that as a "Latin English" advocate, the plural of formula to me should be formulae, but I will let this go, that is not the challenge here.. the challenge here is getting the basics down with formula fields, and understanding the core functions and operators. As I came into this module, I was honestly expecting the use of some things like ISBLANK() to be the climax of advanced formula fields, so even I am now a little nervous about how advanced this might actually get! There is even a little bonus Back to the Future reference in this module. Which you can't miss.



As a personal aside to this module, I would have to say that I have always found it useful/better to actually use the "Insert Field" button to drop fields into formulae... I also quite often use the Function picker on the right to build up my code. Even though typing these things isn't hard. I think it makes it more methodical (and does reduce typos) than just freehanding it all in. The logical flow which you might type "this and that if that or this" might not be the most efficient way to actually evaluate something, and using the function selector makes me evaluate that a little harder.

Anyway, no distractions by personal techniques. We are here to earn all the badges. And besides, Laura has stopped shopping... it appears someone in our family is getting one of these next week:


(I'm lucky none of our relations read my blog...)

Module 2

Laura: Making posh coffees with the machine in the kitchen

Simon:  Using numbers, currencies and percentages in formulas

This is a really good topic, and probably one where I fall foul of the rules more often than not. There is a sub-section in here on the solid use cases for these three different, specific formula types. I'm afraid that I am a bit of a dinosaur myself, and I still don't "believe" in these rich variable types. I just make everything a number, and then deal with the formatting, processing and collateral damage of doing so myself. I could definitely learn something here.

I have also have trouble in the past with "divide by zero" errors in formulae, so it is worth noting the final paragraphs on "treating blanks as zero" - but you should also get into the habit of thinking about zeros being valid amounts. How often do you create a number field with a default of zero for initial values? Consider using an "IF( field__x == 0, 1, field__x)" to instead "divide by 1" - which of course has "no effect" when there is a nill value. (obviously check this makes sense to the business logic first).

Laura rattled through those coffees, so no time for screen shots. A quick espresso and onwards!

Module 3

Laura: Gone upstairs, I think she's on the phone to her mum

Simon: Using Date and Date/Time formula

Ironic this because if I keep up Salesforcing on holiday, I might not get many more dates..
Once again there was some interesting learning in here even for an old hand like myself. DATE functions in formula fields are incredibly powerful. Coming from other programming language libraries being able to call out instances of TODAY and LASTWEEK in reports and rules has always been quite simply dreamy.

The challenge on this module is a little odd, in terms of "business value".. I would probably have one of our BA's go back to this client to establish quite why they wanted the current day of the week on their contact page, but it's still a good example that uses a clever trick outlined in the module ;) - as an extension to this, you could consider taking a Date of Birth field on the contact page, and get Salesforce to output the day of week this contact was born.. You could then even cross reference it with that famous poem about "babies born on a monday" to augment a Description field...

Either way, stack up the points, and prepare to move on. I have to go out now, I have a feeling the conversation is going to be a distant background noise to me now as my head buzzes about the possibilities of the next module.

Module 4

Laura: Back home scrolling instagram for wedding ideas

Simon: Using Picklists in Formulas

I know who's having more fun on the sofa right now (I hope she doesn't look over at my screen). There is one resounding rule regarding Picklists in formulae that they address right at the head of this module: ISPICKVAL() - never forget this.

 

As much as Picklists can LOOK like text, ACT like text and in Apex be TREATED like text - in formulae, you need to address them with the ISPICKVAL function to compare them. I have lost count of the number of times this has caught me out and you eventually conceed "ooohhh, it's a picklist, thats why it doesn't work.". This module makes a good highlight of this, and explains the options you have in the form of CASE and TEXT as well. Most comparisons I make though tend to need ISPICKVAL - as you are plucking out one possible status value for an sObject and then asserting a bunch of rules around it.

Module 5 - the game is up

Laura: Discovered I was on Salesforce, has gone into the other room

Simon: Using text in Formulas

This must be one of the biggest uses of simple formula fields in Salesforce - text manipulation. The examples in this module are exactly on point - concatenating names, turning numerical values into words (like "Hot" and "Cold" leads) - but did you know you can do so much more with text in formula fields? Just last week I tasked one of my colleagues (a fairly new start) with the challenge of replacing a "dirty product" flag with a "red light image" - he stared at me in horror, until I told him to quickly Google it... if I'd know this module existed, I would have sent him straight over here instead.

That is exactly what you are about to embark upon in the challenge. Generating a five-star-review icon in place of a "1-5" numerical grade for Lead quality. This kind of formula field should be kept somewhere safe, as once you know how to do it - you are going to want to put images ALL OVER your page layouts. (with a bit of tinkering, you can get a whole raft of standard salesforce icons, such as traffic lights and 5-star rating, but also Tab icons and other standard imagery, so go have a poke around...!)



I now have to go and make lunch I think, to re-establish communication lines here at home, especially as the next module starts with a video, and I don't have headphones to hand.

Two modules to go

Laura: Has put her shoes on, I think I'm in luck - she's off for a walk

Simon: Levelling up with Advanced Formulas

It seems we have now learnt everything we need to know about advanced formula fields, much like the prodigy in every kung foo movie - it is now time to use what we have learnt. There are some really good tips on best practice formula practises, especially for longer formulae, with a nice 12 month example (which as I read I was sure, this can be simplified) - that is then smashed down to a super-simple 4 liner.

There is a really interesting article linked out from this module "Tips for reducing formula size" - and I am genuinely going to print this out and keep it in my desk drawer at work. My comment in the second paragraph about inter-compiling formulae is addressed in this document, with really good examples of how re-using another formula field repeatedly inside other formula fields will really, really quickly blow you out of the water for maximum formula compile size. Give this a good read, I have found myself applying the "when all else fails use a workflow rule" chapter at least once.

The challenge on this module involves building two formula fields, so read through all the points before starting on it.. you actually want to develop from the bottom up on the challenge bullet points as you will reference your second formula field in your first (which you can't do until you have it).

The final module

So there has been a little beer drinking between the advanced formula module and now, but I have always maintained I do my best coding when I'm more "relaxed".. (I'm not sure how my employer would feel about that mind)

Laura: Wrapping presents on the floor

Simon: Troubleshooting Formula Errors

As I read down these common formula errors, I couldn't help but notice that I was just slowly nodding my head along in agreement with everything they said. Anyone who has worked with formula fields for a few years would have to admit or agree to these errors at some point or other. My suggestion of using the "Insert Field" and double clicking method names really does mitigate errors relating to missing parentheses or parameters because the wizard will fill them in for you as you go.

The second half of this module reiterates the details from the "Tips" document I mentioned earlier in this post - which does just go to indicate it's importance (I knew it!). Being aware of the compilation process and limits is half the battle to not having a problem with it.

This final challenge is a bit of a "spot the bug" one - which if you've ever paid attention to the Bristol Developer User Group that I run - you will know is something of a personal favourite hobby of mine - so I was delighted to recreate this problem and fix it up. Not a problem in the end, just pay attention to your training and you will have this module complete in a heartbeat.




Now I haven't technically earnt this badge yet, as I didn't complete all the challenges (I know, I know, shocked gasps!). But if you would like to find out more about this, or other trailhead modules - get in touch with me and join us on January 7th at 6pm GMT for the Bristol Salesforce Developer User group who will be having a Trailhead meetup that night. Attendance can be physical or digital - we can skype-project you if you want, and I will be earning ALL these new badges that night, for sure!


Whilst I am writing a blog post about Trailhead - whether you need the practise or not - I have to point out that there is now a module for building a Space Battle Station now.... no more boring warehouses for us!

Go earn all the badges!