Teach Me Salesforce

A community approach to learning salesforce.com

Archive for the ‘Apex’ Category

Trailhead Review: Apex Specialist Superbadge

leave a comment »

This article is about my first Trailhead Super Badge, the Apex Specialist.

Challenge 1
Challenge 1 requires a fair amount of declarative admin work to get the objects and components in place to allow you to test in the UI (you could probably write the code without it but it’s important to test in the UI and in code).

Because Trailhead playgrounds use the base Developer Edition architecture, there are also all the usual custom fields and data, so it’s helpful to be familiar with that so that you can easily distinguish the components added by the managed package and those that are in every DE org (like SLAViolation__c).

I predict that the creation of Products in the unit tests could be annoying if it involves adding them to an active Price Book :/

The instructions are appropriately vague, like real-world requirements, and do require you to read them closely to understand the goals of the challenge. I’ll confess that I don’t usually perform Test-Driven Development, but for this Superbadge, I am doing that because it’s way easier to test bulkification with unit tests.

One aspect that I didn’t expect was that I could complete this challenge without implementing everything specified in the Business Requirements for Automate Maintenance Requests. I had intended to include all of those requirements to be thorough and ensure that I passed on the first attempt but for the benefit of you the Reader, I thought I’d see what happens if I checked the challenge before completing everything. I won’t say what I left out because I think that part of the learning process is how to read and execute requirements. And I assume it will be checked in a later challenge…I’ll let you know.

Time so far: 2 hours

Challenge 2
Challenge 2 jumps into callouts, nothing very difficult since the external service is already set up for you, so you just have to retrieve the data and get it added into your Trailhead playground. It requires some of the lessons learned in the Apex Integration Services module to complete.

And I was still able to pass the challenge without completing all the Business Requirements for Automate Maintenance Requests.

Time to complete: 1 hour

Challenge 3
Challenge 3 is the simplest of the challenges so far, although I tried to make it more difficult expecting that I had to complete the requirement entirely in code rather than utilizing some declarative configuration.

Still no check on all the requirements in Automate Maintenance Requests. Maybe they’ll come up in the unit tests.

Time to complete: 30 minutes

Challenge 4
This is the start of the unit test challenges and despite the instructions to create positive and negative tests, the check appears to only care about 100% coverage which I had achieved during my test-driven development in Challenge 1 without negative tests. I did bulkify my original tests because I always do but I wonder if it even checks for that.

It never did check to see whether I completed all the Business Requirements in Automate Maintenance Requests.

Time to complete: 0 minutes (because I built the unit tests during Challenge 1).

Advertisements

Written by Always Thinkin

December 29, 2018 at 1:46 pm

Posted in Apex, Trailhead

Trailhead Review: Quick Start: Apex Coding for Admins

leave a comment »

Review of Quick Start: Apex Coding for Admins

This Project won’t teach you a lot of Apex concepts, but is good practice creating Apex Classes and Triggers in the Setup UI and using Workbench with Anonymous Apex to execute the code. The Steps themselves don’t try to teach you Apex and just involve cutting and pasting code then executing the code, however the comments are thorough, one for each line. The comments use formal terminology to describe each line’s action, so they are a good lesson in speaking “Developer”.

Overall, the instructions could add more detailed conceptual descriptions to help Admins grasp what they are doing, perhaps even comparing the actions to what they might already know from declarative development (e.g. the BankAcct class is similar to a Custom Object with number and text fields, plus a Workflow Field Update that adds numbers).

Step 1 is just about setting up the metadata for this project.

Step 2 is just copying and pasting to create two Apex Classes.

Step 3 is just another copy and paste into Workbench to verify that the previous classes behave as expected.

Step 4 introduces Lists and replaces the code fromStep 2 to include a List.

So far, not many concepts have been discussed in the Trailhead itself, but the comments in the code are thorough and should be read carefully to get the most out of this module.

Step 5 introduces For Loops (although without really explaining what they’re for) and updates an Apex class to include a For Loop.

Step 6 introduces DML, specifically the database insert method to add Contacts.

Step 7 introduces SOQL and updates an Apex class to include a SOQL query.

Step 8 adds a Trigger and tests it by creating a custom object record to verify that the Contact insert from Step 6 works.

 

Written by Always Thinkin

December 9, 2018 at 4:49 pm

Posted in Apex, Beginner

Tagged with

Apex Workshop Webinar 11: Custom Settings

leave a comment »

The video for the workshop session on Apex with Custom Settings can be found on YouTube here:

The trigger and its unit test we worked with in this session is available here:

Written by Always Thinkin

July 8, 2017 at 7:15 pm

Posted in Apex, Beginner, Code Sample

Apex Workshop Webinar 10: Exception Handling

leave a comment »

The video for the workshop session on Apex Exception Handling can be found on YouTube here:

The trigger and its unit test we worked with in this session is available here:

Written by Always Thinkin

July 8, 2017 at 7:05 pm

Posted in Apex, Beginner, Code Sample

Apex Workshop Webinar 9: Unit Tests

leave a comment »

The video for the workshop session on Apex Unit Testing can be found on YouTube here:

The trigger and its unit test we worked with in this session is available here:

Written by Always Thinkin

July 8, 2017 at 7:01 pm

Posted in Apex, Beginner, Code Sample

Apex Workshop Webinar 8: Invocable Apex

leave a comment »

The video for the workshop session on Invocable Apex Classes can be found on YouTube here:

The original source is from a presentation at Dreamforce ’16 based on https://github.com/mshanemc/processBuilderBlocks.
In our session we worked with:
PBB Lock:
https://github.com/mshanemc/processBuilderBlocks/blob/master/src/classes/PBBLock.cls
PBB Delete:
https://github.com/mshanemc/processBuilderBlocks/blob/master/src/classes/PBBDelete.cls
PBB Utility (dedupe):
https://github.com/mshanemc/processBuilderBlocks/blob/master/src/classes/PBBUtilities.cls

Ohad’s String Utility

Written by Always Thinkin

July 8, 2017 at 6:54 pm

Posted in Apex, Beginner, Code Sample

Apex Workshop Webinar 7: Classes

leave a comment »

The video for the workshop session on Apex Classes can be found on YouTube here:

The triggers and their unit tests for practicing are available here:


Written by Always Thinkin

July 8, 2017 at 6:09 pm

Posted in Apex, Beginner, Code Sample