Conversation with Salesforce Co-Founder – Parker Harris

I recently had the opportunity to spend a few minutes with Parker, and was most intrigued by how it could be possible for a CTO of such a large and growing company to stay in the loop with all the latest software developments and innovations.

Often, we spend hours and hours training before we can work on projects.  Parker had recently spoken about Salesforce DX – a brand new feature about to be released  to speed up the process of development cycles, bringing proper development tools for version control.  I was surprised when Parker told me that he likes to spend hands on time with the latest developments when ever he is able. Parker further explained how the night before he spoke about DX – he set up a few of his own scratch org’s and really experimented with the feature.

This made me realize that as a person in the tech industry, I’ve seen many developers working on non-technical work. Most don’t love it! To quote from my conversation with Parker Harris “At heart I am a developer, my happy place is when I am in front of code” – this is amazing life advice, try and always be involved in what you are good at  and what you enjoy.

 

Update Salesforce Records Using Apex (The easy way)

As a Salesforce Admin we often need to update a bunch of records. We often find ourselves downloading the data, manipulating in excel and then doing an update immediately after, which is quite a tedious process.

The fastest way to do this – is to use APEX.

Many admins are scared to even look at code, so I’ve simplified this and hopefully if you follow my steps you’ll be able to adapt this to do whatever you need it to!

I’ve used a simple edit on the status of a case for my example – where we want to take all open phone cases (Origin = Phone) and Close them.

Step 1: (Open the window where the code will run)

Open the developer console and click the menu option Debug – then click Open Execute Anonymous Window (Ctrl+e)

Step 2 (Build Your Query and Chose What You Want to Update)

I’m using the standard Salesforce object for Cases – called case. The update is broken down into 2 parts – firsts we query the records we want to work with and save them to an array – I’ve called this array exactly what it is ‘recordsToUpdate’ – once we save the records we will be working with  – we then loop through them all one by one – I’ve called this ‘singleRecord’ . The loop function is the for – and we are going individually across every record that is saved in our array named ‘recordsToUpdate’.  Inside of this loop is where we manipulate our data – I’ve taken the status and changed it closed:

List<Case> recordsToUpdate = [select Id, status from Case where origin = 'Phone' and isclosed = false limit 100];

for(Case singleRecord: recordsToUpdate) {
 singleRecord.status = 'Closed';
 }
 update recordsToUpdate;

Now, lets say you wanted to update this with your own fields and queries. Quite Simple!

  • Replace ‘Case’ with the object you are working with
  • The query is the select statement – so that also needs to be changed – however remember you need the ID of any record you want to update so leave that there – and if you want to update a record you also need it in the select part of your query.
  • Now the update part singleRecord.status is actually case.status. Let’s adapt that to whatever you will be using – so replace the .status part with whichever field you want to update.
  • Lastly you can add multiple fields to update, just make a new line after the ‘;’ and type SingleRecord.{FieldYouWantToUpdate}  = ‘New Info’;

Always remember when updating records via APEX execute to keep the size small using that Limit at the end of your query.

And as with anything – feel free to reach out to me by clicking Contact Me if you have any questions on how to apply this to your Salesforce used case!