Salesforce II (Apex Focused)

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

18 Terms

1
New cards

Rules when working with databases

RULES:

  • You cannot perform a callout after doing DML (database operations) in the same transaction. You must separate DML and callout using @future.

2
New cards

@future

  • A decorator that runs a method later, asynchronously

  • The new transaction has no uncommited DML and is allowed to make external API callouts

  • When used:

    • To make callouts after DML

    • Separate DML and callouts

    • Offload long-running work

    • Keep UI/Triggers fast

  • Key Rules:

    • Method must be static

    • Must return void

    • Arguments can only be primitive dtypes

  • Exam Tips

    • Use on questions about DML / Callout

3
New cards

@InvocableMethod

  • Method level. Makes a method callable from Flow, Process Builder, or external tools

  • When Used:

    • For no-code Flow automation

    • Integrating Apex with automation tools

    • Calling Apex from a Flow to perform a task.

  • Rules:

    • Must be static

    • Can only accept single-parameter types supported by Flow (list of primitives or sObjects)

  • Exam Tips

    • Use for integration with Flow questions

4
New cards

Database.setSavepoint()

Creates a checkpoint in the current transaction

5
New cards

Database.rollback(savepoint)

rollsback database to the savepoint

6
New cards

@AuraEnabled

  • Method or Property. Exposes Apex methods or properties to Lightning Components (Aura and LWC)

  • Rules

    • Methods must be static to be called from LWC

    • Can specify cacheable=true to allow client-side caching

  • Use cases:

    • Lightning Components calling Apex methods

    • Lightning Data Service Integrations

  • Exam Tips

    • Frequently comes up in Lightning performance and caching questions

7
New cards

@TestMethod / @isTest

  • Method/Class level. Marks methods or classes as unit tests

  • Rules

    • Test methods cannot call future methods directly unless wraped in Test.startTest() / Test.stopTest()

    • Can be used on both classes and methods

  • Use Cases

    • Writing Apex unit tests to satisfy coverage

    • Testing trigger and controller logic

  • Exam Tips

    • PDII focuses heavily on testing best practices

8
New cards

@ReadOnly

  • Method-level. Allows queries in read-only mode within Visualforce controllers or batch operations

  • Rules

    • Cannot perform DML

    • Increases governor limits for queries

  • Use Cases

    • Batch or high-volume query operations

    • Improving performance when only reading records

  • Exam Tips

    • Use for optimization/performance questions

9
New cards

@Schedulable / @Scheduled

  • Class-level. Allows the class to be scheduled to run at a specific time or interval

  • Rules

    • Must implement Schedulable.execute() method

  • Use Cases

    • Nightly updates, periodic reporting, data cleanup

10
New cards

@Batchable / @Database.Batchable

  • Class-level. Marks a class as batch Apex, processing large datasets asynchronously

  • Rules

    • Must implement start(), execute(), and finish()

    • Can be chained with other batch classes

  • Use Cases

    • Large data updates or integrations

11
New cards

@Queueable

  • Method/Class level. Enqueues Apex for asynchronous execution with more flexibility than @future

  • Rules

    • Implements Queueable interface

    • Can chain jobs

    • Supports complex objects as parameters (unlike @future)

  • Use Cases

    • Async callouts with complex objects

    • Background processing in trigger

12
New cards

@Deprecated

  • Method/Class. Marks a method or class as deprecated, signaling that it should not be used in future development

  • Use Cases

    • Legacy code maintenance

13
New cards

@InvocableVariable

  • Property-level. Works with @InvocableMethod to expose input/output variables for Flow or Process Builder

  • Use Cases

    • Define what a Flow is can pass to Apex

    • Define what Apex returns to Flow

14
New cards

@TestSetup

  • Method level. Sets up common test data that can be reused across multiple test methods in a class.

  • Use Cases

    • Reduces code deuplication in tests

    • Improves test performance

15
New cards

@Storable

16
New cards

@SeeAllData

  • Method-level. allows test methods to access org data instead of creating mock records

  • Use Cases

    • Quick testing without creating test records

17
New cards

@RestResource

  • Class Level. Exposes an Apex class as a REST API endpoint

  • Use Cases

    • Create RESTful web services for external systems

18
New cards

@HttpGet / @HttpPost / @HttpPut / @HttpDelete

  • Method-level REST. Designates a method as handling a specific HTTP verb for a REST class

  • Use Cases

    • Implement REST endpoints for CRUD operations