Sunday, 24 January 2021

Salesforce Flows, Triggers and CPU - One. More. Time.


 Introduction

The Spring 21 Salesforce release includes the following update, which will be enforced in Summer 22:


Accurately Measure the CPU Time Consumption of Flows and Processes (Update)

With this update enabled, Salesforce accurately measures, logs, and limits the CPU time consumed by all flows and processes. Previously, the CPU time consumed was occasionally incorrect or misattributed to other automation occurring later in the transaction, such as Apex triggers. Now you can properly identify performance bottlenecks that cause the maximum per-transaction CPU time consumption limit to be exceeded. Also, because CPU time is now accurately counted, flows and processes fail after executing the element, criteria node, or action that pushes a transaction over the CPU limit. We recommend testing all complex flows and processes, which are more likely to exceed this limit.


which I was particularly pleased to see, as it was confirmation of what I'd been seeing since before save flows were introduced in Spring 20, namely that the reporting around flow CPU consumption was off. You can read about the various findings by working back through the blog posts,  but the bottom line was that the debug logs reported hardly any CPU consumption for a flow unless you added an Apex debug log about it, in which case it suddenly jumped up and reported the actual value. In effect the act of looking at how much CPU had been consumed caused it to be consumed, at least from a reporting perspective. For a real transaction the CPU obviously had been consumed, but it wasn't always clear what had consumed it, which no doubt led to a lot of finger pointing between low and pro coders, or ISVs and internal admins.

To close the loop on this, I was really keen to re-run some of my previous tests to see what the "real" figures looked like, or as real as you can get, given that performance profiling of Salesforce automation is affected by so many factors outside your control.  When looking at the results below, always remember that the actual values are likely to be different from org to org - the figures I'm seeing from my latest tests are way faster than a year ago in a scratch org, but your mileage may vary.

Also, don't forget to apply the update - I did and couldn't make head or tail of my first test result!


Methodology

The methodology was the same as for the original before save testing in Spring 20 - I'm inserting a thousand opportunities which are round robin'ed across two hundred accounts and immediately deleting them. This means the figures are inflated by the setup/teardown code, but that is constant across all runs. The debug level was turned down to the minimum and I ran the each test five times and took the average.

The simple flow to update the opportunity name came out at 1172 msec. Just out of curiosity, I added a debug statement to Apex code that does the testing, and lo and behold the average went up to 1374 msec. Here we go again, I thought. Before I published and started fighting on the internet again, I disabled all automation and ran the code again - so inserting and deleting the opportunities with and without the debug statement. The averages were : no debug statement - 1108 msec, with debug - 1140. Nothing conclusive, but it's definitely having an impact. Finally, I enabled my simple trigger to do the same thing as the flow and test this with and without the debug statement. Average without - 897 msec, with - 1216 msec. Given that the average without the debug statement was lower than the average when all automaton had been turned off, I decided that the debug statement ensures an accurate report, especially as it has a similar impact across both flow and trigger numbers. Once again, it's really hard to profile Salesforce performance!

Results


Test Flow Trigger Difference
No automation 1140 1140 0
Update record name 1374 1216 158
Update record name with account info (lookup) 2133 1252 881
Combined trigger (set name) and flow (change amount) 1459 1459 0

As expected, triggers are faster than flows, which is good because that's what Salesforce say! The differences aren't huge for a single record but once you scale up to a thousand records with a little complexity, they can become significant - 881msec might not sound like a lot, but it's 8% of your allowance for a transaction. 

Mixing flow and triggers doesn't bring any penalty, for CPU at least. It makes your automation harder to understand, and may mean you can't guarantee the order that the various types fire in, so it's best avoided regardless of the effect on CPU time.

Proceed With Caution

In a follow up post when after save flows were introduced, I found that I could carry out way more work in a transaction using flows rather than triggers, as whatever checks CPU time from a limits perspective was subject to the same reporting issue. Once this feature is activated, the flow CPU starts counting from the beginning. In Summer 20 I could insert 2-3000 opportunities and keep under the 10000 msec CPU limit, with this feature activated I'm hitting it at the 1-2000 mark, so you might find you've inadvertently been breaking the limit because the platform didn't notice and let you. Definitely run some tests before enabling this in production and, per the update information:

      You can enable the update for a single flow or process by configuring it to run in API version 51.0 or later.

so you can start testing on a flow by flow basis.

Hopefully this is the last post I'll have to write on this topic - it's been a wild ride, but it feels like we've reached the end of the road. 

Related Posts



Saturday, 16 January 2021

Remote Working - together, isolated

Introduction

As we move into the third week of 2021, the UK is working through the world's worst movie franchise - now showing : Lockdown 3 - Lockdown Harder (but not as hard as Lockdown 1). We're all hopeful that Lockdown 4 - Lockdown without a Vaccine is permanently cancelled, but that remains to be seen.

Everyone that is able to is back working from home and ordering everything they need via the internet. I saw this situation described on twitter recently as "the middle class stay at home while the working class bring them things", which sums it up quite nicely.

The Tech Wars aren't Over

But they have changed.  Back in the day it used to be desktop operating systems - Linux, Windows or Mac. Then came the rise of the mobile device and it was iOS or Android. Sometimes it was programming languages - C++ or Java. In Salesforce we have the UI - Lightning or Classic, and the development paradigm - No, Low, or Pro Code.

In the world of remote work we can now argue about chairs, air purifiers, mechanical versus membrane keyboards, standing desks, microphones and webcams, along with side skirmishes about LED lighting and cable routing. If you aren't engaged in any of these battles, you might want to read some of the billions of blog posts that have been written in the last 10 months about "the perfect home working setup". There's probably been another couple of hundred written while you've been reading this paragraph, so don't delay.

The Great Normalisation (and other upsides)

One upside is the acceptance that working from home doesn't mean your home suddenly becomes a professional office. Children and pets wandering in to video calls is the new normal and not something to be mortified about. In fact, it's not just accepted, but often a welcome break for the hostages desperately waiting for the call to end. A home is a shared resource, and we must all be good multi-tenant citizens and not hog the space.

Community events are mostly virtual, including the Dream'/London's Calling behemoths. While we miss seeing each other in person, this is another upside. When we had to fly all over the world to attend or present, it definitely favoured those earning Western European/US style salaries with passports that gave visa free access to lots of countries. If you were from a wealthy country, you had far more opportunity to raise your profile in the community than someone who needed to wait months for a visa and spend a week's wages on one night in a London hotel. 

What Does the Future Hold

(This is obviously forward looking, and the following is nothing more than my opinion)

There will be no in-person Dreamforce in 2021. The figures in the US are still horrific, and Europe isn't that much better. While it seems likely the vaccine will reduce the death toll by protecting those most at risk, it will take more than a couple months and, as usual, the developed world will take priority. I can't see Salesforce wanting to be the company that brings 100k+ people from anywhere to San Francisco and gets blamed for the next flare up. There will almost certainly be some testing requirements for any in-person events for the rest of the year, and the logistics of that would be overwhelming at that scale - anyone who has been to a World Tour event with metal detectors can attest to that. A gradual return to normal event attendance seems more likely to me, and I can't see a socially distanced Dreamforce with 5k attendees appealing to Marc Benioff and co.

The same goes for the London Salesforce Developers. In the UK right now (16th Jan) we are seeing around 50k+ new cases a day, which is flattening but will take some time to go down. We are likely to stay in a highly restricted environment for a couple of months followed by a gradual easing. It's hard to see any company wanting to open up their offices to bunch of people who could have been mixing with anyone, and speaking as an organiser, I don't want to be remembered as one of the team behind a super spreader event.

Realistically it feels to me like it will be 2022 before we restart the kind of events that aren't vital to an industry, and it will only be when things like football, rugby and the theatre are running at full capacity  that the community-minded events start getting back up to speed. I also think that hybrid events, with a mix of in person and virtual sessions, will be the future. Before then, if we can get back to some kind of normality where I can mix with one or two of my friends and neighbours in my local pub I'll be happy.

Looking a bit further out, I don't think the remote working genie is going back into the bottle. While there will be a return to the office after the pandemic is over, people new to the job market have only known this, will have mostly enjoyed the experience, and will be expecting this to be offered by any company they talk to in the future. They will eventually be the generation of leaders, and will be pushing for more remote when they are in a position of influence. It might take a decade or two, but the days of everyone commuting to an office will seem as quaint as taking your celebration food to the village bakehouse for cooking now does to those of us who live in Europe.

Related Posts

Saturday, 9 January 2021

Org Documentor - A Little More Configuration


Overview


I received a feature request in the Org Documentor Github repository this week, which didn't come as a huge surprise as it was from one of my colleagues (Firoz Mirza, who has featured before in this blog) and I'd asked him to raise it. The ask was to make the report title in the home page configurable, rather than the 'Org Report' that is generated by default.

I try to keep the switches on plug-ins of this nature as simple as possible, preferring to keep the granular behaviour in the config file, otherwise you start to run out of letters. I also don't like making people configure behaviour that they don't care about, so if there is no title in the config file, the default of 'Org Report' will be used.

It made sense to make the subtitle configurable, so you can add the following to your json config file to configure one or both of these - in this case I've chosen a title of 'Instance Overview' and a subtitle of 'From the metadata source' :

{
    "title": "Instance Overview",
    "subtitle": "From the metadata source",
    "objects": {
      ...
    }
}

After updating my installed plug-in to the latest version (3.4.3) and executing the doc command against my sample Salesforce metadata, I'm pleased to see that my home page has picked up the changes:


You may also notice the the README has been updated for the plug-in - I left this as the autogenerated version created when building the plug-in, and it was pointed out to me recently that it suggests using npm install to install the plug-in, rather than the sfdx plugins:install command (thanks Lawrence Newcombe!).


Plug-in


Version 3.4 of the plug-in has this new functionality and can be found on NPM

If you already have the plug-in installed, just run sfdx plugins:update to upgrade to 3.4.

if you aren't already using it, check out the dedicated page to read more about how to install and configure it.

The source code for the plug-in can be found in the Github repository.

Related Posts

Sunday, 3 January 2021

2020 Year in Review - Part 4

Behind the scenes in the Trailblazer Lounge

October

The London Salesforce Developers gave ourselves a break from organising meetups this month, as we said a fond farewell to Richard Clark and welcomed Erika McEvilly as our new co-organiser.

BrightFORUM launched on the app exchange - our second lightning bolt. I appeared on a couple of podcasts - Salesforce Developer Podcast with Josh Birk and the SFDC Consultant Podcast with Emeric Gabor. 

Einstein Analytics became Tableau CRM. Dreamforce to You was announced, consisting of a Keynote, meetings with account execs(!) and DreamTX for learning about new features and best practice.

November

The UK went back into lockdown for four weeks. Not the same as the first lockdown though, so another word would really have been a better idea. London Salesforce Developers resumed our events programme with a session on our (and others) favourite tools. This was really enjoyable as we had a load of speakers (from the UK, Moscow, USA and the Philippines) who gave us the highlights of their favourite tool and what was great about it. I came away with a list of items to look at that I'm still working through.

The second EMEA cohort of Speaker Academy started their course.

I appeared on a panel for the Ashburn Women in Tech, along with Melissa Hill Dees and Domenique Buxton, to talk about my Salesforce journey. Once again, something that would have been impossible to do in person.

Salesforce reported to be interested in buying Slack. As the Dreamforce keynote was only a week or two away, seemed highly likely this deal was going to complete very soon. Salesforce UK&I got a new CEO from Accenture - Zahra Bahroloumi.

December

The new word for lockdown type events was in place when we came out of Lockdown 2 - Tier. Three tiers were created, with hardly anywhere in the lowest level of tier 1. I was in tier 2 for a couple of weeks, then tier 3 for a few days, then into the newly created tier 4 with Christmas cancelled at 5 days notice. This left me with a 15lb turkey and enough of everything to feed 10 people. Safe to say my freezer is well stocked for the New Year.

As is traditional, the Salesforce London Developer, Admin and Women in Tech groups combined for the Xmas Megameet - a look back at our year, a quiz from Peter Chittum, scavenger hunts, ugly jumpers, wine and mince pies. It's a bit of an odd one to carry out virtually, especially given the sheer number of attendees, but great fun. 

I appeared with Jodi on Supermums podcast to talk about Speaker Academy - 3 podcasts in a couple of months, definitely a sign of the times.

The Dreamforce to You agenda was released - keynote on Dec 2nd followed by four days of learning with DreamTX from 13th-17th December. I was lucky enough to be offered a place in the Trailblazer lounge for the fourth (Trailhead) day, which was a blast. The only downside is you don't get to see the sessions as they are broadcast, but the upside is you get to meet a bunch of great people from around the world, and find out a lot more about what goes into this aspect of the event.

Related Posts

Saturday, 2 January 2021

2020 Year in Review - Part 3

July

The London Salesforce Developers held our TrailheaDX Global Gathering. Sadly a lot of this was us explaining how we'd failed to get on to any of the pilots and talking about things rather than demoing them. We still had fun though, which is the main thing.

The EMEA cohort of Speaker Academy completed their six week course and started prepping for their graduation event where they would give a 5 minute lightning talk to a live audience. It's an interesting mixture of relief that the course is over and trepidation that they have to put what they've learnt into practice in front of a bunch of people they don't know.

The Salesforce Summer 20 release went live, and the BrightGen webinar went virtual - not a massive change, but you do miss being able to look over at your co-presenter to see if there are any problems or questions. This release included the Lightning Message Service going GA, and flows that could now be run after a record was saved, getting ever closer to parity with triggers.

Salesforce's inexorable growth continued as their market cap hit $180 billion, passing Oracle's $174 billion. Richard Socher stepped down as Salesforce Chief Scientist to start his own company. 

The UK lockdown officially ended as pubs were allowed to open again!

August

The August meet of the London Salesforce Developers was a Speaker Academy takeover, as our first EMEA cohort gave their graduation talks to an appreciative audience drawn from the developer, admin and women in tech groups. 

As the pandemic started to hit the US, Salesforce had pledged no layoffs for 90 days - this clearly expired in August as 1,000 jobs were cut. In the continuing story of the whole world going virtual, Salesforce replaced Exxon Mobil in the Dow Jones Industrial Average. Marc Benioff also hinted at no digital Dreamforce this year, which sent the community into a bit of a tailspin. 

The UK government launched "Eat Out to Help Out" - an initiative that allowed pubs and restaurant to offer discounted meals Mon-Wed. This was intended to get the economy moving and give people the confidence to mix in public again, but also had the effect of increasing infections - encouraging large numbers of people to congregate indoors was still a bad idea it appeared.

September 

The London Salesforce Developers September meetup was on data factories and presented by Nikos Mitrakis - another remote presenter who would have found it more difficult to attend in person. 

As I took a well earned break from Speaker Academy, a Trailhead badge that I'd written content for was released - Salesforce Skills and Experience Building 

After the layoffs the previous month, Salesforce announced they were creating 4,000 jobs - hopefully giving some of those laid off a better chance of finding another position. There were also a bunch of "new product" announcements : 

Salesforce Meetings - bringing the virtual meeting experience inside Salesforce while still running on third party technology. 

Digital 360 - which felt rather like a repackaging of existing features with an E-Commerce slant. 

Work.com for Vaccines - to help governments and healthcare organisations manage large scale vaccine rollouts (several months before it was needed, it turns out).

The UK continued to open up - I was able to go for a couple of weeks holiday in Norfolk and even go to a few pubs and tea shops. Always socially distanced, but the weather was still glorious so I was mostly walking my dogs on the beach or sat with them in pub gardens. I kept reminding myself (and others) that every other pandemic in history had a second wave, and there was no reason why this time it would be different.

Related Posts

 

Friday, 1 January 2021

2020 Year in Review - Part 2



Three months of lockdown took a toll on the grounds of the beach house!


April

April was notable for a full lockdown in the UK, which moved everything that wasn't nailed down into the virtual space. The London Salesforce Developers had their first event run on Zoom, which gave us significant pause for thought as we'd seen a number of reports of Zoom bombing in the media and were keen not to be another example of lax security. Todd Halfpenny and I had a couple of trial runs were we locked everything down and then tried to cause trouble, which were calmed our nerves. Like many things, it's very difficult to guarantee it won't happen, but if you make people register, maintain control of microphone and screen sharing, and be ready to boot anyone that steps out of line you can be fairly confident you won't have a disaster. We had a great turnout to hear Anup Jadhav talk about event driven architecture, no doubt helped by the fact that everyone was stuck at home. We also welcomed attendees from around the world, which was an unexpected upside. The networking in this first event went on for some considerable time, as everyone was a bit starved of company and needing some form of human interaction. This pattern didn't continue though, as people adjusted to the new normal pretty rapidly. 

At BrightGen we took the view that you can't over-communicate when you are working remotely, so each team had regular social/coffee break calls and there was a company-wide pub quiz at regular intervals. Again this turned out to be something that wasn't required every week, but while it was needed there was plenty of it. Probably the hardest aspect was onboarding the new joiners - building those key relationships is harder when the casual conversations around the office aren't possible. On the upside, we saw a huge surge in lunch and learn, both in terms of sessions and attendance. With so much time on our hands, we were keen to make good use of it. We also had the virtual Grand National sweepstake - no prizes in this format, so obviously for the first time in my life I had the winner - Potters Corner!

In an announcement that surprised nobody, Salesforce announced that Dreamforce would be virtual in 2020, as would all their other events. 

May

Emboldened by the success of our first virtual meetup, the London Salesforce Developers pressed on with Devs Love Low Code Too, presented by Narinder Singh. Another great turnout, with attendees from around the world. We were also remarking how much easier it was to organise these events when you don't need a venue and catering! "Have Zoom account, will meetup" was now our mantra. 

Come the 13th May we weren't stuck in front of our screens for quite so much time, as the lockdown started to slowly lift and we were allowed out for exercise as much as we liked, including meeting one person outside who wasn't part of our household! It was like Christmas come early (and pretty much identical to my actual Christmas it turned out).

Jodi Wagner and I onboarded two new teachers for Speaker Academy (Amber Boaz and Julia Doctoroff) so that we could split into EMEA and US cohorts. Somehow this took a four hour Zoom call, and in my case a surprising amount of rum and coke.

Salesforce launched Work.com to help companies return to the office, which in hindsight seems quite optimistic. Gavin Patterson continued his rise to fame at Salesforce, becoming President and Chief Revenue Officer. 

June

The London Salesforce Developers June Meetup saw David Reed join us from the USA to present on Automating the Development Lifecycle with Cumulus CI - something we'd probably have struggled to achieve in person! The Speaker Academy signup for the EMEA cohort attracted 50 applicants for 6 spaces and we kicked off the first session on June 4th.  The restrictions relaxed further in the UK and we were allowed to travel as far as we liked for exercise, although we still had to return the same day. 

The Summer 20 release notes became available in beta, starting another of the thrice-yearly races to get the first blog post out about the key features. 

The much anticipated TrailheaDX took place, re-imagined as a virtual event that bore a striking resemblance to the actual event but with more of a marketing spin. It's fair to say the response to this was positive, but it was nothing like as well received as the in-person event. The chat aspect seemed particularly problematic, descending into an avalanche of spam after a few minutes. Moving events online wasn't something that only Salesforce were wrestling with - I attended what seemed like hundreds during this time and nobody really came up with anything different to a mix of recorded and live sessions, and a virtual expo that wasn't well patronised. 

But the days were long, the weather in the UK was glorious, the COVID-19 case numbers were dropping and it looked like things would be opening up more in the near future.

Thursday, 31 December 2020

2020 Year in Review - Part 1


January

2020 started quietly, like any other. The first London meetup was Einstein Analytics where the number of people doing dry January meant that there was more than enough booze to for the rest of us. The following day was the London Salesforce Developers, where 60 odd people headed over to PWC's offices to hear about Heroku and the Spring 21 release of Salesforce. London's Calling needed bios and headshots, and tickets were selling like hotcakes. 

There were also reports of a virus in the Wuhan province of China that was highly contagious - this didn't feel like something we had to worry about as (a) it was a long way away and (b) we'd seen this kind of thing before with SARS, swine flu and bird flu in the past. Towards the end of the month there were a few cases in other countries, but easily explained through international travel. On the last day of the month the UK recorded it's first case, along with fellow European countries Sweden and Spain. Again, very much a case of someone bringing it with them on holiday and easily contained.

February

Two meetups for the Developers in February. First a fireside chat with Wade Wegner at Salesforce Tower on 5th, talking about Evergreen (now Salesforce Functions) and more. Little did we know this would be the last trip to the tower of 2020.  Then on 12th we had our Dreamforce Global Gathering at Deloitte's offices in Clerkenwell Green. Little did we know (2) that this would be the last time we would meet in person. 

Spring 20 went live and I presented a release webinar with my colleague Clive Platt. Little did we know ... you get the picture. This brought the new mobile app to all users, and introduced the WITH SECURITY_ENFORCED SOQL clause and the Security.stripInaccessible() method to bolster security in Apex. What a time to be alive!

The COVID-19 virus was still around  - by Feb 6 there were 30 odd cases in Europe which led me to mention it when sending my London's Calling slide deck - a throwaway remark hoping that it didn't derail us. It still seemed a very low risk, and likely something that would level out quickly - in the UK we only had a couple of cases. Fast forward to the end of the month and we still had under 20 cases Looking over to Europe, the case count in Italy was rapidly increasing. Around this time things started to change as we realised that it was likely to be problematic, although human nature still made us expect that things wouldn't be too bad. At BrightGen we started planning for how we'd shift most/all of our workforce to remote, with a dry run day scheduled for March.

March

The London Salesforce Developers decided not to hold a meetup in March, as the London's Calling community conference was taking place and that typically consumes most of the community's energy. At BrightGen we'd had our dry run day in early March with everyone working from home and it had been pretty straightforward. Which was handy as we went completely remote the following week, although with offices still open for the odd face to face meeting. 

The Salesforce World Tour London, due the third Thursday in May, was postponed. By the end of the month TrailheaDX had gone virtual and become a half day or so event. 

As everywhere started to shut down, or operate at a much reduced capacity, I had to make a trip to a testing centre in Stratford to take my JavaScript Developer 1 exam. After a weird journey where I shared a whole carriage with about 10 other people in rush hour, I arrived at a deserted Stratford that would usually be bustling. I had an hour to spare in a ghost town where not much was open and there was nowhere for a casual visitor to sit inside with a coffee and carry out some last minute revision. So I wandered the streets while reviewing my notes and did my best to avoid going within 6 feet of anyone else. After the test I headed back home on a carriage with about 8 other people, as the London's Calling speaker drinks scheduled for that evening had been cancelled due to the ever increasing virus.

London's Calling had tried to stay in-person, but eventually gave up the battle and went all remote, with the exception of a few speakers, including myself. This involved another trip to London, this time sharing the carriage with 5 other people and arriving at an eerily quiet Liverpool Street, which typically resembles the zombie apocalypse at that time of the morning. A strange day then commenced of a group of speakers shuffling from one room to another to support each other, moving the chairs into corners of the room and generally avoiding each other while trying to network with each other. I personally had the pleasure of presenting to the cavernous and almost totally empty keynote room - this was actually a great experience as I had to still give my best even in the absence of an audience and in a somewhat uncomfortable environment. Whatever doesn't kill you makes you stronger. I'm not sure the organisers would agree though, having pivoted from an in person to virtual event at a few days notice, and spending a lot of the day finding out the limitations of the various livestream event platforms! 

After a happy hour involving a live band and highly distanced drinks and dancing, I headed home sharing the carriage with 3 other people, wondering how long the trains would continue to run with so few passengers. This was also the last day that the pubs were allowed to open, in an attempt to slow the spread of the virus, and they were packed both inside and out until closing time. It didn't seem like this was going to help much, and it didn't. A mere three days later we were locked down and only allowed out for an hour's exercise a day.

I'd been asked to present at the Finland Developer Group on 25th March. It was always going to be remote, but as I was preparing my talk it started to feel like a vision of my future. Short term future, though, which turned out to be all kinds of wrong!

Related Posts