Skip to main content

Top 100 Most common used Apex Method in Salesforce

 


Here are 100 more Apex methods in Salesforce:


1.      insert: Inserts records into the database.

2.      update: Updates records in the database.

3.      delete: Deletes records from the database.

4.      upsert: Updates or inserts records into the database.

5.      query: Retrieves records from the database using SOQL.

6.      getContent: Retrieves the content of a document or attachment.

7.      getContentAsPDF: Generates a PDF file from a Visualforce page or HTML content.

8.      addError: Adds a custom error message to a record and prevents saving.

9.      start: Initiates processing in batch Apex.

10.   execute: Processes a batch of records in batch Apex.

11.   finish: Finalizes processing in batch Apex.

12.   equals: Compares two objects for equality.

13.   clone: Creates a deep copy of an object.

14.   getInstance: Obtains an instance of a specific record type.

15.   sendEmail: Sends an email using the Apex Messaging classes.

16.   toLabel: Retrieves the translated label for a field or picklist value.

17.   size: Determines the number of elements in a collection.

18.   substring: Extracts a portion of a string.

19.   contains: Checks if a string contains a specific substring.

20.   Math.min: Returns the smaller of two numeric values.

21.   Math.max: Returns the larger of two numeric values.

22.   JSON.serialize: Converts an Apex object into a JSON string.

23.   JSON.deserialize: Converts a JSON string into an Apex object.

24.   System.debug: Logs debugging information.

25.   Database.rollback: Rolls back changes made within a transaction.

26.   Test.startTest: Resets governor limits in unit tests.

27.   Schema.getGlobalDescribe: Retrieves a map of all available sObject types.

28.   Schema.SObjectType: Obtains the sObject token for a given sObject type.

29.   UserInfo.getUserId: Retrieves the user ID of the current user.

30.   Limits.getLimitQueries: Retrieves the maximum number of SOQL queries allowed in the current context.

31.   String.isBlank: Checks if a string is null, empty, or contains only whitespace.

32.   String.valueOf: Converts an object into its equivalent String representation.

33.   List.add: Adds an element to a list.

34.   List.remove: Removes an element from a list.

35.   List.size: Returns the number of elements in a list.

36.   Map.put: Adds a key-value pair to a map.

37.   Map.get: Retrieves the value associated with a key from a map.

38.   Map.containsKey: Checks if a map contains a specific key.

39.   Set.add: Adds an element to a set.

40.   Set.contains: Checks if a set contains a specific element.

41.   Date.today: Returns the current date.

42.   Date.newInstance: Creates a new Date instance with the specified year, month, and day.

43.   DateTime.now: Returns the current date and time.

44.   System.assert: Checks that a boolean expression is true and throws an exception if false.

45.   Test.isRunningTest: Checks if the code is running in a test context.

46.   Test.setMock: Sets a mock response for a callout in a test.

47.   Math.round: Rounds a decimal number to the nearest whole number.

48.   Math.random: Generates a random decimal number between 0 and 1.

49.   Math.abs: Returns the absolute value of a number.

50.   EncodingUtil.base64Encode: Encodes a string or blob into a base64-encoded string.

51.   String.join: Joins elements of a list into a single string using a delimiter.

52.   String.split: Splits a string into an array of substrings based on a delimiter.

53.   String.replace: Replaces occurrences of a substring in a string with another substring.

54.   String.startsWith: Checks if a string starts with a specified prefix.

55.   String.endsWith: Checks if a string ends with a specified suffix.

56.   String.toLowerCase: Converts a string to lowercase.

57.   String.toUpperCase: Converts a string to uppercase.

58.   Database.queryLocator: Represents a query locator object for large data sets in batch Apex.

59.   Database.getQueryLocator: Converts a SOQL query into a query locator object.

60.   Database.BatchableContext: Represents the execution context of a batch Apex job.

61.   System.runAs: Executes a block of code with different user context for testing purposes.

62.   System.schedule: Schedules an Apex job to run at a specified time.

63.   System.abortJob: Aborts a scheduled Apex job.

64.   System.today: Returns the current date in the user's time zone.

65.   System.now: Returns the current date and time in the user's time zone.

66.   System.today: Returns the current date in the user's time zone.

67.   String.isBlank: Checks if a string is null, empty, or contains only whitespace.

68.   String.isNotBlank: Checks if a string is not null, not empty, and not containing only whitespace.

69.   String.substringBefore: Returns the substring before the first occurrence of a delimiter.

70.   String.substringAfter: Returns the substring after the first occurrence of a delimiter.

71.   String.trim: Removes leading and trailing whitespace from a string.

72.   String.containsIgnoreCase: Checks if a string contains a specific substring, ignoring case.

73.   String.isBlank: Checks if a string is null, empty, or contains only whitespace.

74.   String.isNotBlank: Checks if a string is not null, not empty, and not containing only whitespace.

75.   List.size: Returns the number of elements in a list.

76.   List.isEmpty: Checks if a list is empty.

77.   List.sort: Sorts the elements of a list in ascending order.

78.   List.reverse: Reverses the order of elements in a list.

79.   Map.keySet: Returns a set containing all keys of a map.

80.   Map.values: Returns a list containing all values of a map.

81.   Map.isEmpty: Checks if a map is empty.

82.   Set.size: Returns the number of elements in a set.

83.   Set.isEmpty: Checks if a set is empty.

84.   JSON.serializePretty: Converts an Apex object into a formatted, human-readable JSON string.

85.   JSON.deserializeStrict: Converts a JSON string into an Apex object, strictly enforcing object structure.

86.   JSON.deserializeUntyped: Converts a JSON string into an untyped Apex object.

87.   Test.startTest: Resets governor limits and starts a new set of test execution context.

88.   Test.stopTest: Stops the execution of test code and validates governor limits.

89.   Test.isRunningTest: Checks if the code is running in a test context.

90.   Test.setMock: Sets a mock response for a callout in a test.

91.   Test.loadData: Loads test data from a CSV file for use in unit tests.

92.   Date.format: Formats a date into a string using a specified date format.

93.   DateTime.format: Formats a datetime into a string using a specified datetime format.

94.   Math.round: Rounds a decimal number to the nearest whole number.

95.   Math.floor: Rounds a decimal number down to the nearest whole number.

96.   Math.ceil: Rounds a decimal number up to the nearest whole number.

97.   EncodingUtil.base64Decode: Decodes a base64-encoded string into a blob.

98.   Blob.valueOf: Converts a string into a blob.

99.   Test.isRunningTest: Checks if the code is running in a test context.

10.Database.rollback: Rolls back changes made within a transaction.


Comments

Popular Posts

How to create ICS/Calendar File | Helps you to download the calendar invites

  Want to know how to create ICS(Internet Calendar Scheduling) file for Business purpose....đź‘€    ICS (Internet Calendar Scheduling) file is a calendar file saved in a universal calendar format used by several email and calendar programs, including Microsoft Outlook, Google Calendar, Notes and Apple Calendar. It enables users to publish and share calendar information on the web and over email. Lets see the code. The code is written in lwc(Lightning web component). HTML:   <template> <div class="login-container"> <h1 style="size: 14px;"><b>Create ICS File</b></h1> <div class="form-group"> <lightning-input type="datetime" name="input1" value={EventEndValue} onchange={startDate} label="Enter Start date/time value" ></lightning-input> </div> <div class="form-group"> <lightning-input type="...

Salesforce Flow Updates – Spring’25 Release

  In this blog, we’ll dive into the Salesforce Flow Updates introduced in the Spring ’25 Release. We’ll explore their practical applications and how they enhance user experiences. This release emphasizes improved usability, efficiency, and functionality in Salesforce Flows. With upgrades like enhanced Flow Builder features, reactive screen actions, and progress indicators, Spring ’25 takes automation to the next level. Let’s explore each Salesforce Flow Updates 1. View Flow Versions Side by Side The Spring ’25 update introduces the ability to open flow versions in separate tabs directly within the Flow Builder. This feature allows you to compare different versions side by side on the same canvas, streamlining the debugging process and improving efficiency. 2.Smarter Search in Resource Picker The resource picker now features enhanced nested search functionality, simplifying the process of finding the right resources. Whether you're looking for record variables, custom labels, or glo...

Sharing records by Apex in Salesforce

  Greetings, everyone! In today's session, we'll delve into the topic of sharing records within an Apex class. As we're aware, there exist various methods through which we can accomplish the sharing of records. We engage in record sharing primarily when the object's Organization Wide Default (OWD) settings are set to private. Sharing settings come into play when certain predefined criteria are met, allowing us to extend access to records to designated groups or roles. In cases where intricate logic is involved, manual sharing is employed. While this approach proves beneficial for specific records, instances where a multitude of records require automated handling, Apex sharing becomes the preferred solution. Salesforce offers a 'Share' object for each type of object, with distinct naming conventions: For standard objects, it's 'StandardobjectName+Share', such as 'AccountShare' for the 'Account' object. Custom objects follow the pattern...

Capture Real time data using CDC(Change Data Capture) in Salesforce | SF Fact #05

Change Data Capture (CDC) enables receiving near-real-time updates for Salesforce records and synchronizing them with an external data store. CDC publishes change events that reflect modifications to Salesforce records, including new records, updates, deletions, and undeletions. These events can be subscribed to in a Lightning Web Component (LWC) using the Emp API. To meet the business requirement of creating a task whenever a user manually changes an opportunity's status to "Closed Won," use CDC events and a generic LWC on the opportunity record page. This solution avoids the need for Apex triggers or record-triggered flows. How to enable CDC? Go to setup Search Change Data Capture Add Entities The  lightning/empApi  module provides access to methods for subscribing to a streaming channel and listening to event messages. All streaming channels are supported, including channels for platform events, PushTopic events, generic events, and Change Data Capture events. This co...