Christmas Special : Upto 40% OFF! + 2 free courses - SCHEDULE CALL
Salesforce, Inc. is a cloud computing and SaaS provider. In general, Method can be defined as a programming approach which is declared as a component of the class, which may include objects of the class if any or a simple way to define a method is a procedure that is made up of several statements that work together to complete an operation. In Apex methods are the same as the general methods.
A method generally consists of Modifiers, Return Type, Method Name, Parameters, and a Method body. Now let us see in detail about the Methods in Salesforce.
Numerous Methods in Salesforce can be applied to organise data depending on various data types.
The following are the Methods in Salesforce for collections:-
Set methods are part of a set class, which is responsible for collecting unique items when copying object values are not allowed. In Salesforce, set methods are most useful because they operate on sets, which are ordered groups of items created using the Set keypad. Salesforce Integration Cloud offers an individual view of customer data for huge businesses and organizations. It helps users connect huge amounts of data scattered across different cloud platforms. Sign up for an industry-oriented Salesforce developer training program to provide you with more advanced exposure in the field of Salesforce.
We all know that the elements of a set may either have a specified or a built-in data type, or they can have a data type that is completely arbitrary. One of the most well-known types of methods is the instance method, but there is another kind of method that points us in the direction of performing an operation on a specific method: set methods. For the various sets of data, we also need a set Constructor and set method. Set methods are part of a set class, which is in charge of collecting unique items whose object values cannot be duplicated. As the name implies, set procedures in Salesforce rely on sets, which are ordered groups of items that may be established using the Set keyboard shortcut. Take your cloud computing awareness to another level with cloud computing courses.
It is used for the insertion of an element into the set.
It is used for the process of adding together the whole list of components that make up a certain set. After invoking a specific method and then verifying that the items being added do not appear elsewhere on the list of sets, it is possible to proceed with the adding procedure.
It is useful for adding all of the components that are included in a given setlist. When these components are not already included in the set's element list, this step is taken to accommodate them.
It is useful in the process of removing all of the items in the set that has been defined. clear() methods have a syntax that looks like this: public void clear (). The value that is returned has a type of "void."
It is useful in the process of making a replica of the set that may be used more than once. The syntax looks like this: public set object clone () The type of the value that is returned by the set method is Set (of the same type).
It is helpful in returning the true value in case of the list of set if containing all the required elements of a particular set list.
It is helpful in returning the true value in case of the set if containing all the due number of elements of a particular set.
It is helpful in removing or deleting the elements which are present in a specific list of set if there are already present inside the original set list.
It is helpful in removing or deleting the elements which are present in a specific set if there are already present inside the original set.
To put it simply, an index is used to uniquely identify each item in a list. Any basic type, collection, sObject, custom type, or built-in Apex type may be used for a list's element.
It is possible to stack lists inside one another to create multidimensional lists that may contain any collection. An array of arrays is one way to organise a collection of Integers, for instance. There may be a maximum of five layers of nesting inside a list, with each level containing one more collection.
The List keyword and the type of the data to be stored in the list (primitive data, sObject, nested list, map, or set) enclosed in > characters constitute a valid list declaration.
// Make an empty list of String Listmy _list = new list (); // Create a nested list List >> my_list_2 = new List
>>(); To access elements in a list, use the List methods provided by Apex. For example: List
myList = new List (); myList.add(47); Integer i = myList.get(0); myList.set(0, 1); myList.clear();
To add an element
Inserts an element into the list at the specified index position.
Adds each of the items that are included in the set or list that has been supplied to the list that is calling the method. It is required that both lists have the same structure.
Adds each of the items that are included in the set or list that has been supplied to the list that is calling the method. It is required that both lists have the same structure.
Prepare the beginning of the list. Brings the size of the list down to zero.
Makes a duplicate copy of a list
Performs a comparison of the lists and returns true if they are identical. This anticipates that the order will be consistent throughout all of the listings.
Returns the list element for a specified index.
To check if list is empty or not. Returns true if list is empty
Removes list element at a specified index
Replace a list element at a specified index.
Returns the number of elements in a list.
Sorts the items in a list
A map is a collection of classes, each of which is made up of a collection of components. It is a combination of a key and a value. Each and every one of the map's elements has both a key and a value associated with it. The key has to be one of a kind, but the value may be repeated. It allows for memory to be allocated dynamically. It's kind of like a collection of key-value pairs, except that each key (which is unique) only maps to one value. Both the keys and values may be any form of data.
Creating a Map:
Mapvariablename=new Map (); In salesforce, we have standard object Account, If we want to map id with account, it is represented as, Map Accmap=new Map (); Example:- Map mapname=new Map (); mapname.put(‘Green’,’trouser’); mapname.put(‘blue’,’pants’); mapname.put(‘black’,’ trouser’); When the above is executed with both mapname.keyset() and mapname.values() method we will get the values as for keyset:{green, blue, black} for values:{ trouser, pant, trouser }.
From this, we can see that values can be duplicated.
If we try to duplicate key, it overrides the existing key and gives the output with the key that is given at last.
String Class Salesforce is essentially a class variable that is comprised of a variety of Apex String Methods, and it is through the use of these specific String methods that Alt-text users are granted the ability to carry out varied activities using a variety of strings. Therefore, a string class is produced in Salesforce whenever these String Methods are used with one another.
The String is a collection of characters that does not have any restrictions placed on it. Within Salesforce, there are a number of different techniques for String.
1. ToLowerCase() Converts all characters in the String to lowercase using the default (English US) locale rules
2. ToUpperCase() Converts all of the characters in the String to uppercase using the rules of the default (English US) locale.
3. Capitalize() Returns the current String with the first letter changed to title case.
4. Contains(substring) Returns true if and only if the String that called the method contains the specified sequence of characters in substring.
5. ContainsIgnoreCase (substring) Returns true if the current String contains any of the characters in the specified String; otherwise, returns false
6. ContainsAny(inputString) Returns true if the current String contains any of the characters in the specified String; otherwise, returns false
7. ContainsNone(inputString) Returns true if the current String doesn’t contain any of the characters in the specified String; otherwise, returns false.
8. ContainsOnly(inputString) Returns true if the current String contains characters only from the specified sequence of characters and not any other characters; otherwise, returns false.
9. StartsWith(prefix) Returns true if the String that called the method begins with the specified prefix.
10. StartsWithIgnoreCase (prefix) Returns true if the current String begins with the specified prefix regardless of the prefix case.
11. E ndsWith(suffix) Returns true if the String that called the method ends with the specified suffix.
12. EndsWithIgnoreCase (suffix) Returns true if the String that called the method ends with the specified suffix.
13. Substring(startIndex) Returns a new String that begins with the character at the specified zero-based startIndex and extends to the end of the String.
14. Substring (startIndex, endIndex) Returns a new String that begins with the character at the specified zero-based startIndex and extends to the character at endIndex - 1.
15. SubstringAfter(separator) Returns the substring that occurs after the first occurrence of the specified separator.
16. SubstringBefore(separator) Returns the substring that occurs before the first occurrence of the specified separator.
17. Trim() Returns a copy of the string that no longer contains any leading or trailing white space characters
18. Equals(stringOrId) This function will return the value true if the object that was handed in is not null and it represents the same binary sequence of characters as the string that is currently being accessed. You may compare a string to an object that represents a string or an ID by using this method.
19. EqualsIgnoreCase (secondString) This function will return true if the object that was handed in is not null and it represents the same binary sequence of characters as the string that is currently being used. Comparing a string to an object that represents a string or an ID may be done with the help of this method.
20. SwapCase() Performs a case change on every character and then returns the String that has been created in the default locale (English, United States).
As we can see there are numerous Methods in Salesforce corresponding to various data types. In which each performs a unique operation. Methods can be of two types pre-defined and user-defined. Pre-defined, as the name itself says that these are already defined and cannot be modified but whereas user defined methods are the methods declared by the users corresponding to their requirement. So one must know how and where to use these methods in order to gain maximum production.
Salesforce Course Training
How To Convert Lookup To Master-Detail?
What Are External And Big Objects In Salesforce?
Cyber Security
QA
Salesforce
Business Analyst
MS SQL Server
Data Science
DevOps
Hadoop
Python
Artificial Intelligence
Machine Learning
Tableau
Download Syllabus
Get Complete Course Syllabus
Enroll For Demo Class
It will take less than a minute
Tutorials
Interviews
You must be logged in to post a comment