Tag: Data Type

  • What are Data Types in Apex in 2023?

    What are Data Types in Apex in 2023?

    What is a Data Type in Salesforce Apex?

    In Salesforce Apex, a data type is like a category or a label that tells the computer what kind of information is stored in a variable (a storage box for information). It helps the computer understand how to handle and work with that information.

    How Many Types of Data Are There in Salesforce Apex?

    There are different types of data in Salesforce Apex, and they can be grouped into two main categories:

    1. Data Types: These are the basic building blocks.

    Below mentioned are the data types in Salesforce Apex:

    • Blob: Represents binary data.

    Blob myBlob = Blob.valueOf(‘Hello, World!’);

    • Boolean: Represents true or false values.

    Boolean isTrue = true;

    • Date: Represents a date without a time component.

    Date myDate = Date.today();

    • DateTime: Represents a date and time.

    Datetime myDatetime = Datetime.now();

    • Decimal: Represents a number with decimal places.

    Decimal myDecimal = 42.2;

    • Double: Represents a 64-bit double-precision number.

    Double myDouble = 42.2;

    • ID: Represents a record ID.

    ID recordId = ‘001XXXXXXXXXXXXXXX’;

    • Integer: Represents whole numbers.

    Integer myInt = 42;

    • Long: Represents large whole numbers.

    Long myLong = 4200000000;

    • String: Represents a sequence of characters.

    String myString = ‘Hello, World!’;

    • Time: Represents a specific time of day.

    Time MyTime = Time.newInstance(12, 30, 0, 0);

    dont miss out iconDon’t forget to check out: Custom Metadata Types: Your Recipe for API Key Security

    2. Collections in Salesforce: A collection in Salesforce Apex is like a basket where you can put many things together. It’s a special box that allows you to keep multiple pieces of information in one place. There are three main types:

    • List: A list is like a shopping list where you can write down and keep many items in order.
      • Order Matters: In a list, the order of items is important. Each item has a specific position, called an index, and you can access items using their index.
      • Use When Order Matters: Use a list when the order of items is meaningful, like a sequence of steps or a timeline.

    Example: Adding and Accessing:

    List<String> fruits = new List<String>{'Apple', 'Orange', 'Banana'}; fruits.add('Grapes');
    // Adds 'Grapes' to the end of the list
    String myFruit = fruits[1];
    // Accesses the second item ('Orange') using the index

    • Set: A set is like a collection of unique treasures. It only keeps one of each kind.

      • No Duplicates: Sets don’t allow duplicate values. If you try to add the same item twice, it only keeps one.
      • Use When You Need Uniqueness: Use a set when you want to make sure each item is unique, like keeping track of distinct values.

    Example: Ensuring Uniqueness:

    Set<Integer> uniqueNumbers = new Set<Integer>{1, 2, 3, 3, 4};
    // The set will only have 1, 2, 3, and 4, eliminating the duplicate '3'.

    • Map: A map is like a dictionary where you match one thing with another. For example, you match a name with a phone number.
    • Key-Value Pairs: Maps store information as key-value pairs. Each key is unique, and it maps to a specific value.
    • Use for Associations: Use a map when you want to associate one piece of information with another, like matching names with ages. Collections help keep your information organized, like putting all your toys in one box or all your books on one shelf. They make it easier for your computer program to work with lots of data at once
    • Example: Associating Information:

    Map<String, Integer> ages = new Map<String, Integer>{'Alice' => 25, 'Bob' => 30, 'Charlie' => 22};
    Integer bobAge = ages.get('Bob'); 
    // Retrieves the age of 'Bob'.

    • sObject Data Type: In Salesforce, a sObject is like a special container that holds data for a specific type of object, such as an Account, Contact, or Custom Object.

    Example – Creating a sObject

    Account myAccount = new Account(Name='My Company', Industry='Technology');

    Here, myAccount is an instance of the Account sObject, holding information like the company name and industry.

    • Fields and Properties: A sObject has fields, which are like slots where you can store specific types of information (e.g., Name, Industry).

    You access and modify these fields using dot notation.

    • Use for Database Operations: sObjects are often used when interacting with the Salesforce database. You can create, update, and query records using sObjects.

    Example

    // Creating a new Account record and inserting it into the database.
    Account newAccount = new Account(Name='New Company', Industry='Finance');
    insert newAccount;

    • Custom Objects: sObjects aren’t just limited to standard objects like Account; they can also represent custom objects you create in Salesforce.

    Example

    // Creating an instance of a custom object named 'Custom_Object__c'.
    Custom_Object__c customRecord = new
    Custom_Object__c(Name='Custom Record');

    In simple terms, think of a sObject as a special box that holds all the details about a specific type of thing in Salesforce, whether it’s a standard object provided by Salesforce or a custom object you’ve designed. It helps you work with and manipulate data related to that specific type of object.

    • Enum Data Type: An Enum, short for Enumeration, is a special data type in Salesforce Apex that defines a set of named constant values.

      Defining an Enum:

      public enum DayOfWeek {
          MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
      }

      Here, DayOfWeek is an Enum that represents the days of the week as constant values.

      Using Enum Values:

      You can use Enum values to represent specific, predefined options in your code using Enum Values:

      DayOfWeek today = DayOfWeek.WEDNESDAY;

      Now, today holds the constant value representing Wednesday.

      dont miss out iconCheck out another amazing blog by Bhawana here: What are Apex Basics? A Guide in 2023

      Conclusion

      In simple terms, an Enum in Salesforce Apex is like a list of predefined options that you can use in your code. It helps make your code more readable and less error-prone by providing clear, named values for specific scenarios. Enums are especially useful when you want to represent a set of constant values that belong together.

    • What is the External ID in Salesforce and Data Wizard? | All You Need to Know

      What is the External ID in Salesforce and Data Wizard? | All You Need to Know

      In Salesforce, an external ID is a unique identifier for records generated outside of Salesforce. This is a custom field that can be added to any object and used to reference records in Salesforce from external systems. 

      External IDs help you integrate data between Salesforce and other systems by providing a way to match records across different databases. External IDs let you automatically sync and update data between Salesforce and external systems without manual intervention. 

      External IDs can be set as text, auto-number, number, and email fields and marked as unique so that each record has a unique identifier. You can also create indexes to retrieve data faster and support efficient queries. 

      Salesforce allows you to create up to 25 external IDs per object. However, the number of external IDs you can create may vary depending on which edition of Salesforce you have and the number of custom fields available in your org. 

      Note that external IDs count against the total custom field limit. So if you hit your custom field limit, you may not be able to create additional external IDs. External IDs can affect data import, export, and query performance in Salesforce, so it’s also important to carefully plan and consider your business needs before creating external IDs. 

      dont miss out iconDon’t forget to check out: Classes and Objects in Salesforce | Tutorial Video

      Advantages

      There are several advantages of using External IDs in Salesforce: 

      1. Integrate: External identities provide a more efficient way to integrate data between Salesforce and other systems. External IDs make it easy to match records across different systems, simplifying data synchronization and ensuring data consistency across systems. 
      2. Unique Identifier: The external ID provides a unique identifier for the record that can be used to reference it from other systems. This avoids duplication and confusion when working with data in different systems. 
      3. Query optimization: Using the external ID as a unique identifier allows you to optimize your queries to retrieve data faster. Indexing external IDs can speed up data retrieval and improve performance when working with large datasets. 
      4. Migrate data: You can migrate data from other systems to Salesforce using external identities. Mapping external IDs to Salesforce records makes importing data easier and ensures that it’s correctly linked to existing records. 
      5. Business logic: External IDs can be used to support complex business logic that requires referencing data across different systems. External identities allow you to create custom workflows and automation based on data from external systems, helping streamline business processes and improve efficiency. Overall, external identities provide a powerful way to integrate data across disparate systems, support complex business logic, streamline queries, and improve performance.

      dont miss out iconCheck out another amazing blog by Navdita here: What is the Einstein Bot? | The Ultimate Guide

      Cons

      While external IDs in Salesforce have some advantages, there are also some potential disadvantages to consider. 

      1. Availability Limit: Salesforce has a limit of 25 external IDs per object. This means that if you have multiple points of integration or complex data requirements, you may run out of available external identities. 
      2. Maintenance: Adding or removing external IDs can impact your data model as it requires changing the relationships between records. This can make maintaining and changing your Salesforce org more difficult. 
      3. Performance: External IDs can improve query performance, but they can also slow down data imports and exports if not used properly. This is because Salesforce must validate external IDs when importing data, which can add overhead and processing time. 
      4. Complexity: Managing external identities can add complexity to your data model, especially if you need to track multiple external identities across different objects. This can make the data difficult to understand and manipulate over time. 
      5. Security: External IDs can be used to reference data from external systems. This can pose security concerns when sensitive data is involved. Before implementing external identities in your organization, it’s important to carefully consider the security implications of using external identities. Overall, external IDs provide a convenient way to integrate data between Salesforce and other systems, but they come with certain complexities and potential performance implications that you should carefully consider before implementing them in your organization, also poses problems.
    • All You Need to Know About Database Class Methods to Perform DML Operations

      All You Need to Know About Database Class Methods to Perform DML Operations

      In this blog, we will discuss Database class methods to perform DML operations. So let’s get to the topic.

      • Apex contains the built-in database class.
      • Database classes provide methods that can perform DML operations.
      • Database class methods are static and called through the name of the class.
        • Database.insert()
        • Database.update()
        • Database.upsert()
        • Database.delete()
      • Database methods have an optional allorNone parameter.
      • This parameter allows you to specify whether the operation should partially succeed.
      • When this parameter is set to false, if an error occurs on a partial set of records, then the successful records will be committed and errors will be returned for the failed records.
      • No exceptions are thrown with the partial success option.
      • This feature is not available with DML statements.

      dont miss out iconDon’t forget to check out: DML Statements vs Database Methods in Salesforce

      Example  

      Database.insert ( recordList,false);

      The database methods return result objects containing the success or failure information of each record.

      Database.insert and Database.update 

      For insert & update operations an array of Database.SaveResult objects are returned.

      Database.SaveResult results [] = Database.insert(recordList, false);

      Let’s take an example to understand this:

      //create a list of contacts 
      List<Contact> contactList = new List<Contact> 
      { 
          new Contact(FirstName=’name1’,LastName=’person1’), 
          new Contact(FirstName=’name2’,LastName=’person2’), 
          new Contact()}; 
      //Bulk insert all contacts with one DML call 
          Database.SaveResult[] srList = Database.insert(contactList, false); 
      //Iterate through each returned result 
          For (Database.SaveResult sr : srList)
          { 
              if( sr.isSuccess()) 
              { 
      //Operation was successful, so get the ID of the record that was processed 
              System.debug(‘contact inserted’ + sr.getID()); 
              }
              else
              { 
      //operation failed, so get all errors 
              for(Database.Error err : sr.getErrors()) { 
              System.debug(err.getStatusCode() + err.getMessage()); 
              System.debug(‘Contact fields that affected this error:’ + err.getFields()); 
              } 
          } 
      }

      Database.upsert and Database.delete 

      • Database.upsert( recordList,false);
      • Database.UpsertResult results [] = Database.upsert(recordList,false);
      • Database.delete( recordList, false);
      • Database.DeleteResult results [] = Database.delete(recordList,false);
      • By default allorNone parameter is true, so these all are same:
      • Insert contactList; OR, Databaseinsert(contactList), OR Database.insert(contactList,true)

      dont miss out iconCheck out another amazing blog by Bhawana here: DML Operations in Apex: All You Need to Know

      What to Use DML Statement or Database Methods? 

      • Use DML statements if you want to throw errors through apex exceptions and handle them with try and catch block.
      • Use Database methods if you want to allow the partial success of a bulk operation. In this way, successful records will be committed and errors will be returned for the failed records.
      • Database methods can also throw exceptions similar to DML statements.

      This is all about Database class methods to perform insert, update, upsert, and delete operations in apex. I hope this information is helpful to you.

    • DML Operations in Apex: All You Need to Know

      DML Operations in Apex: All You Need to Know

      In this Blog, we will study DML Operations in Apex.

      • DML is used to insert, update, delete and undelete records. 
      • We can use upsert to either insert or update a record. 
      • We also use merge when duplicate leads, contacts and accounts are present and merge them into one record, others are deleted and related records are reparented. 
      • We should always perform DML operations in bulk. 
      • We can handle exceptions. 

      Insert Records 

      • Example of Inserting Only One Record 
      Account acc = new Account(Name=’Tech School’, Phone=’123456’); 
      insert acc;
      • Fetch the Id of the Inserted Record 
      System.debug(‘Acc ID = >‘ + acc.id);
      • Inserting Records in Bulk using List 
      List<Account> accList = new List<Account>(); 
      Account acc = new Account(Name=’record1’ , Phone=’12345’); 
      Account acc1=new Account(Name=’record2’ , Phone=’12543'); 
      accList.add(acc); 
      acclist.add(acc1); 
      Insert accList;
      • Governor Limit Check
        • Inserting two records separately then two DML will be counted. 
        • But if we insert two records through a list then one DML will be counted. 
      • Inserting Related Records, for example first insert account and then contact
      Account acc = new Account(Name=’record1’ , Phone=’12345’); 
      insert acc; 
      Contact con = new Contact(Name=’abc’ , LastName=’xyz’ , AccountId=acc.id); 
      insert con;

      dont miss out iconDon’t forget to check out: Best Practices to Avoid Excessive SOAP and REST API DML | Salesforce Developer Guide

      Update Records 

      • Query an Existing Record and Print its Values
      Account acc= [Select Id,Name,Phone FROM Account Where Name=’record1’]; 
      System.debug(‘acc=>'+acc);
      • Then, Update the Record and do Update DML
      acc.phone=’654321’; 
      update acc;
      • Now, Query the Updated Record
      Account updatedAcc=[Select Id,Name,Phone FROM Account Where Name=’record1’];
      • Now apply System.assertEqual to Validate Update 
      System.assertEquals(updatedAcc.phone,acc.phone,’unequal’);
      • Update Related Records
      Contact con = [Select ID,FirstName,LastName,Phone,Account.phone From Contact where FirstName=’abc’ AND LastName=’xyz’ and AccountId!=null); 
      con.phone=’12365’; 
      con.Account.Phone=’12111’; 
      update con; 
      update con.Account;

      So, in this way firstly contact record will be updated, and after that its related account will also be updated. 

      dont miss out iconCheck out another amazing blog by Bhawana here: Learn All About Collections in Salesforce: List, Set and Map

      Upsert Records 

      This operation allows us to Create one record and update the existing one using upsert DML. 

      Here we can use a list to upsert records. 

      List<Account> accList=new List<Account>(); 
      Account acc1= new Account(Name=’record1’,Phone=’12765’); 
      Account acc2=[Select ID,Name,Phone FROM Account WHERE Name=’record2’]; 
      accList.add(acc1); 
      accList.add(acc2); 
      Upsert accList;

      Merge Records 

      • So only lead, Contact and Account records can be merged. 
      • We can only merge up to three records of the same sObject type into one. 
      • For example, if three leads have the same value then we can merge them into one same goes for contact and account records. 
      • After merging the records, the old record will be deleted and merged into a new one. 

      So, record 1 has related contact and record 2 does not have any related contact then if we merge them then we can have related contact in record 2 as well. 

      Account mergeinto=[Select ID,Name,Phone FROM Account WHERE Name=’record2’]; 
      Account mergefrom=[Select ID,Name,Phone FROM Account WHERE Name=’record1’]; 
      Merge mergeinto mergefrom;

      Delete Records 

      • Apply SOQL. 
      • Now delete queried records using delete DML. 
      Account acc= [Select Id,Name,Phone FROM Account Where Name=’record1’]; 
      delete acc; 
      And to delete more than one record you can create list. 
      List<Account> acc= [Select Id,Name,Phone FROM Account Where Name=’record1’]; 
      delete acc;

      Undelete Records 

      • Insert a record. 
      • Delete that record. 
      • Now query deleted records using all rows in the query. 

      All rows will query all the records whether they are deleted or undeleted. 

      • Then apply undelete statement. 
      Account deletedacc= [Select Id,Name,Phone FROM Account Where Name=’record1’ ALL ROWS]; 
      undelete deletedacc;

      DML Statement Exception 

      Apply to try and catch to handle exceptions raised when DML operations fail. 

      try{ 
      Account acc = new Account(); 
      insert acc; 
      } 
      catch(DMLException e){ 
      System.debug(‘Error=>' + e.getMessage()); 
      }

      So, this will show all the DML errors which will appear while performing DML operations inside the org. Such as here, in this case, we can see that the account record is created without a name so it will show an error. 

    • What is External ID in Salesforce – The Definitive Guide

      What is External ID in Salesforce – The Definitive Guide

      In this blog, we will discuss the External ID in Salesforce. So, An External ID is a custom field that has the External ID attribute, which means that it contains unique record identifiers from a system outside of Salesforce. 

      The maximum number of external IDs an object may have in Salesforce is around up to 25 External ID fields per object. 

      The types of fields which can be used as an external IDs in Salesforce are only custom fields with data type text, numbers, or email as external IDs. 

      dont miss out iconDon’t forget to check out: Classes and Objects in Salesforce | Tutorial Video

      Now let’s understand some important points to consider before working with external IDs: 

      • An External ID field contains record IDs from systems outside Salesforce. 
      • We can only use the upsert call to match against the External ID fields during import or integration in the org. 
      • The values in this external ID field must also be unique and we can also determine whether or not values are case-sensitive. 
      • Custom fields marked as unique also count against an object limit of external id fields. 
      • When a field is marked as external Id, the field will be automatically indexed, so selective filters on them should be run quickly. 

      What is the Use of External ID in Salesforce:

      • It becomes searchable in the sidebar search. 
      • Salesforce record ID is not required to load data. 
      • It can be used with UPSERT DML operation to integrate with other systems. 
      • The data import wizard detects existing records in Salesforce with external IDs that match those values in the import file. 

      dont miss out iconCheck out another amazing blog by Bhawana here: Subscribe to Dashboards and Reports (Salesforce Lightning Experience)

      To Create a Field and Set it as an External ID field: 

      Step 1: Go to setup and select Object Manager and then select any object. 

      Step 2: Now go to the custom field and relationship section and click New. 

      Step 3: In the Data type list, select a data type for the field. 

      Step 4: Enter the details for the field and select the field label, length, Field Name, and Description. 

      Step 5: Check the External ID box, and click Next. Set the field-level security and then click next and then save. 

      The field marked as external ID is created. Now we can use that field as an external ID. 

    • Knowledge of Salesforce Flow and Different Type of Flows and Its Elements

      Knowledge of Salesforce Flow and Different Type of Flows and Its Elements

      What are Flows?

      In Salesforce, a flow is an application that automates complex business processes. Simply put, it collects data and then does something with that data. Flow Builder is the declarative interface used to build individual flows. Flow Builder can be used to build code-like logic without using a programming language.

      Different Types of Flows:

      The Salesforce Flow can be classified into five subtypes:

      1. Screen flows: It can be called using a button or an action or displayed in a Lightning Page or the Utility Bar. It appears as a screen for the user to interact with. Screen flow cannot be automatically triggered.
      2. Schedule-triggered flows: It runs automatically on a recurring schedule. It is helpful for jobs performed frequently or on a schedule (once, daily, weekly). It will run on the defined particular time on the particular Schedule (once, daily, weekly).
      3. Auto-launched flows: These can be called Apex, Process Builder, or another Flow. They can perform actions automatically behind the scenes.
      4. Record-triggered flows: It begins when a record is created or updated. Its functionality is similar to Process builder.
      5. Platform Event-triggered flow: These are called when a platform event is received.

      Type of Flows

      Type of Flows

      Flow Building Blocks

      Flows use three building blocks: elements, connectors, and resources.

        1. Elements are nodes on the canvas that makes things happen. To add an element to the canvas, click Add element.
        2. Connectors are lines on the canvas that define the path the flow takes when it runs. They tell the flow which element to execute next.
        3. Resources are containers that don’t appear on the canvas but are referenced by the flow’s elements. Each resource contains a value or a formula that resolves to a value. For example, your flow can search for an account’s ID, store that ID in a variable, and later use that variable to tell the flow which accounts to update.

      dont miss out iconDon’t forget to check out: Update Related Record Using Salesforce Flow – A Complete Guide

      Types of Elements:

        1. Interaction – Flows can interact with users by presenting questions and information on a screen, or by sending various types of communications. The Screen element and the Action element make these interactions possible.

      Interaction

        1. Data – Data elements instruct the flow to interact with records in the Salesforce database. Use data elements to look up, create, update, and delete Salesforce records. You can work with one record at a time, or many records all at once.

      Data elements

        1. Logic – With logic elements, you can evaluate that data and manipulate it according to your business requirements.

      logic elements

      Connectors: Connectors define the path that the flow takes as it runs. They tell the flow which element to execute next. There are different types of connectors that tell the flow to take a different path in certain circumstances, but most of the time, the flow follows its connectors from one element to the next.

      What Is a Variable?

      In a flow, a variable is a container that holds a piece of information. Flow stores values in variables, but those values can be changed by the flow.

      Why Do I Need Variables?

        • In a screen flow, store the ID of the record that the flow is displayed on, so you can tell the flow which records to update at the end of the flow.

        • Store a number value that can be higher or lower depending on user choices.

        • Store the result of joining two text strings together.

        • Retrieve record values to use in calculations, copy to another record, or display to a user.

        • Assemble a collection of values that you can use to create a record.

        • Make changes to every record that meets certain criteria.

        • Delete every record that meets certain criteria.

        • Keep a running tally of how many times a loop has run.

      What Can I Store in a Variable?

        1. Text: A string of letters, numbers, and characters. If you just need to store a Salesforce ID, and not a whole record, use a text variable.
        2. Number, Currency: A numerical value. Don’t include any currency symbols, such as $ or €.
        3. Boolean: A true or false value. These variables can only contain the True, False, or Empty String global constants.
        4. Date, Date/Time: A specially formatted value that indicates a specific date, or a specific time on a specific date. See Valid Date and DateTime Formats for info on how to format date and date/time data.
        5. Record: All of the values in a Salesforce record, are stored together in a single variable. Each value maintains its own data type, just like in a Salesforce record. The flow can retrieve or update each value individually.

      Advantages of Flows:

      1. Admin maintainability
      2. Built-In version control
      3. Custom components
      4. Collections variables
      5. User-friendly debugging

      dont miss out iconCheck out another amazing blog by Aman here: Knowledge of Sandboxes | Types of Sandbox in Salesforce

      Disadvantages of Flows:

        • Learning curve (as a developer)

        • Code less complicated for some use cases

        • Missing capabilities that code has:

        1. Maps
        2. Upserts
        3. Partial DML Operations

      Please follow this module for Hands-On Experience.

        • Record Triggered Flows

        • Flow Builder

        • Flow Basics

        • Screen Flow Distribution

    • Learn All About Objects and Fields in Salesforce | Salesforce Developer Guide

      Learn All About Objects and Fields in Salesforce | Salesforce Developer Guide

      Objects 

      • Objects are database tables that allow us to store data and information specific to the organization in Salesforce. 
      • We can store data and information unique to the organization in Salesforce by using objects, which are database tables. 
      • Users can interact with data by using objects. 
      • The concept of objects is similar to database table.  
      • Object fields are similar in concept to a database column. 
      • Records in objects are similar in concept to a database row. 

      Types of Objects 

      • There are two types of objects in Salesforce: 
        •  Standard Objects 
        • Custom Objects 

      Standard Objects 

      • Standard objects are the kind of objects that are provided by salesforce.com. 
      • Standard Objects are the objects which already exist in the Salesforce platform to manage the configurations and settings of the environment. 
      • Account, Contact, and User are some of the various standard objects provided by the salesforce. 
      • We can customize the standard objects with the help of custom fields. 

      Custom Objects 

      • Custom Objects are those objects that are created by users to store information that’s specific to the company or industry. 
      • User can add all the fields required in the custom objects. 

      dont miss out iconDon’t forget to check out: Find Newly Created Fields in Salesforce

       Fields 

      • Fields in Salesforce represent what the columns represent in relational databases. 
      • Field can store data values which are required for a particular object in a record. 
      • Every standard and custom object has fields attached to it. 

       Types Of Fields 

      • There are two types of fields in the Salesforce: 
        • Standard Fields 
        • Custom Fields  

      Standard Fields 

      • Standard fields are predefined fields that are included as standard within the Salesforce application 
      • Standard fields cannot be deleted, but non-required standard fields can be removed from page layouts whenever needed. 
      • Both standard and custom objects contain a few common standard fields. 
      • For example –  Name, CreateDate, LastModifiedDate, and Owner fields. 

      Custom Fields 

      • Custom Fields are the fields that are created by the user on standard or custom objects according to their requirements. 
      • Every field has a data type 
      • A data type indicates what kind of information the field stores. 
      • Salesforce supports a bunch of different data types. 

      dont miss out iconCheck out an amazing Salesforce infographic here: 5 Advantages of Using The Salesforce Data Migration Tool in Your Organization

       The custom fields provided by Salesforce are: 

      • Auto Number – Auto Number is used to assign a unique number to every record automatically. 
      • Checkbox – Checkbox allows a user to check a box, indicating a true or false attribute of a record. 
      • Currency – Currency helps the user to enter a currency amount. 
      • Date – Date allows users to enter a date or pick a date from popup calendar. 
      • Date/Time – Date/Time allows users to enter a date or pick a date from popup calendar. They can also add the current date and time by clicking the date and time link next to the field. 
      • Email – Email allows users to enter an email address of up to 80 characters, which is validated to ensure proper format. 
      • Geolocation – Geolocation allows users to specify a location by its latitude and longitude. 
      • Number – Number allows users to enter any number. The number is treated as real number and any leading zeroes are removed. Percent – Percent allows users to enter a percentage number as a decimal. 
      • Phone – Phone allows users to enter any phone number. Character limit is 40. 
      • Picklist – Picklist allows users to select a single value from a list that you defined. 
      • Picklist(Multi-select) – Picklist(Multi-select) allows users to select more than one value from a list that you defined. 
      • Text – Text allows users to enter any combination of letters, numbers or symbols. 
      • Text(Encrypted) – Text(Encrypted) allows users to enter any combination of letters, numbers or symbols. 
      • Text Area – Text Area allows users to enter characters that display on separate lines similar to a Description field. 
      • Text Area(Long) – Text Area(Long) allows users to enter up to 131,072 characters that display on separate lines similar to a Description field. You can set the length of this field type to a lower limit, if desired. Any length from 256 to 131,072 characters is allowed. The default is 32,768 characters. 
      • Text Area(Rich) – With the use of a toolbar, users can format the field content and add images and hyperlinks. The toolbar allows the user to undo, redo, bold, italicize, underline, strike-out, add a hyperlink, upload or link to an image, modify alignment, add a numbered or non-numbered list, indent and outdent. 
      • Url – Url allows users to enter to enter up to 255 characters of any valid website address. 
    • Lookup Relationship in Salesforce – Here’s All You Need to Know

      Lookup Relationship in Salesforce – Here’s All You Need to Know

      Introduction

      Lookup Relationship is an object type relationship in Salesforce. It is one to one or one to many relationships between two objects.

      Some Features of Lookup Relationship:

      • It creates a Loosely Coupled relationship between parent and child objects.
      • In lookup relationships, there is no need to select parent object records in the child object record.
      • There is no cascade record deletion between parent and child objects. This means if you delete parent records then your child record cannot be deleted.
      • The lookup field is not required on the page layout of child objects.
      • You cannot create a rollup summary field on the parent object record when two objects relate to each other in a lookup relationship.
      • It is not necessary to select a parent object record while creating a child object record.
      • This relationship can happen between two standard objects or two custom objects or standard-custom objects.
      • Both Parent and Child Objects have their own Security Control and Sharing Setting.
      • By default record ownership of child, records are not controlled by the parent object.

      How to Create a Lookup Relationship Field

      Step – 1: Go to set up.

      Step – 2: Click on the ‘Object Manager’.

      Step – 3: Select your child object. Here I select ‘Institute’ Object as child object.

      Step – 4: Now click on ‘Fields and Relationships’.

      Step – 5: Click on the ‘New’ button to create a Lookup relationship field on Institute Object.

      Step – 6: Select Lookup relationship data type and click on the ‘Next’ button.

      dont miss out iconDon’t forget to check out: Types of Relationships in Salesforce – All You Need to Know

      Step – 7: Here you have to select your parent object from the drop-down menu in the ‘Related to’ field. Here I select the ‘Student’ object as the parent object. You can select any standard or custom object as the parent object.

      Step – 8: Click on the ‘Next’ button.

      Step – 9: Fill in the details for the Lookup relationship:

      1. Field Label: Here you have to write the name of your lookup relationship field. Generally, we use the parent object name as a lookup relationship field on the child object. Here I use the parent object name ‘Student’ as a field label.
      2. Field Name: It automatically catches the field label name.
      3. Description: You can write a description of your field.
      4. Help Text: You can write about your field information here.
      5. Child Relationship Name: Hereby default your child object name is assigned by salesforce. Here ‘Institutes’ is already present in plural form.
      6. Required: By checking this checkbox you can make this field required on the object.
      7. What to do if the lookup record is deleted? : Here you can choose any one option from the given.
      8. Auto-add to custom report type: It will be available for the custom report type and it is by default checked.

      Step – 10: Now click on the ‘Next’ button.

      Step – 11: Here you can select the visibility of this field for different profiles. Here I select visible to all. You can also manage field-level security here by allowing some profiles of this field as ‘Read Only’ and clicking on the ‘Next’.

      Step – 12: Now you can manage this field assignment to the page layout of the Institute object i.e on your child object. Here is by default assign this field to the page layout of the institute object. And then click on ‘Next’.

      dont miss out iconCheck out another amazing blog by Rajat here: How to Add Your Visualforce Page in your Application as a Tab | Salesforce Guide

      Step – 13: Now you have to add these institute records on a related list of your parent record i.e. student’s records. This checkbox is by default checked.

      Step – 14: Now click on the ‘Save’ button.

      Hence your Lookup Relationship is created successfully and it will be available on ‘Fields and Relationships’ of your Institute object.

      Also, Institute object’s records will be available on student’s objects records related list.

      I hope this information will be helpful for you.

      Thank you!!!

    • How To Create Custom Settings And Custom Objects | Salesforce Developer Guide

      How To Create Custom Settings And Custom Objects | Salesforce Developer Guide

      Custom Settings

      Custom settings are similar to custom objects which allow us to customize org data.

      Following are the steps to create Custom settings:-

      1. Login into your Salesforce org. From Setup, search custom in the quick find box and click on Custom Settings.

      2. Click on New to create a custom setting.

      3. Enter GoogleDrive in the Label field.

      4. Enter again GoogleDrive in the Object Name field.

      5. Select Hierarchy in Setting Type leave as it is if already selected.

      6. Select Public invisibility.

      7. Enter “Creating relation between Salesforce and GoogleDrive.” in the Description field.

      8. Click Save.

      Hence, custom settings are created and now we can add new fields to it.

      9. From the custom field section click on New.

      dont miss out iconDon’t forget to check out: Creation Of An Object In Salesforce | Salesforce Custom Objects

      Here we have a limited data type compared to custom objects.

      i.e,

      • Checkbox
      • Currency
      • Date
      • Date/Time 
      • Email
      • Number
      • Percent
      • Phone 
      • Text
      • Text Area
      • URL

      10. Select Text data type to create a text field.

      11. Click Next.

      12. Enter Customer Name in Field label.

      13. Enter 18 in the Length field.

      As we can see, the Field Name value appears automatically.

      14. Leave the rest of the things as it is and click Next.

      15. Click Save.

       Finally, our custom setting is ready and we can manage it as per our requirements.

      Custom Object

      Steps to create custom objects are:-

      Step 1:- Login into your Salesforce org., and click on ‘Setup’.

      Step 2:- Click on ‘Object Manager’ and then click on ‘New Object’.

      Step 3:- Enter ‘Bank’ in the ‘Label’ field. And enter ‘Banks’ in the ‘Plural Label’ field.

       Leave unchecked ‘start with vowel sound’ and  ‘Object Name’ will appear automatically.

      Step 4:- In optional features, check ‘Allow reports’ and ‘Track field history’.

      Step 5:- In search status, Check ‘Allow search’.

      Step 6:- In ‘Object Creation Options’, check  ‘Add Notes and Attachments related list to default page layout’.

      Leave other fields and checkboxes as it is.

      Step 7:- Click on save.

      Your object is created And now, you can add fields to the object.

      Step 8:- Click on Field and relations. And then click ‘New’.

      In the new custom field page, there is a list of data types to create fields of your choice as required.

      dont miss out iconCheck out another amazing blog by Anshu Raj here: Learn All About Apex in Salesforce | The Developer Guide

      Step 9:- In the new custom field page, select ‘Text’ data type and click Next.

      Step 10:- Enter ‘Customer Name’ in the label field.

      Step 11:- Enter 18 in the Length field.

      The field name will appear automatically.

      Step 12:- Leave others as it is and click on Next.

      Step 13:- Again, leave others as it is and click on Next.

      Step 14:- Click on Save. 

      Like this, you can make other fields also on custom objects Bank by using different data types.

      And then you have to create a Tab for a custom object Bank to show this object in the Salesforce app.

    • Learn About Query Languages & DML in Salesforce

      Learn About Query Languages & DML in Salesforce

      To fetch data, we have a query language in Salesforce. Below are the database query languages in Salesforce.

      • SOQL – Salesforce object query language
      • SOSL – Salesforce object search language

      These two languages help us to deal with databases, to fetch needed data.

      Why Do We Need Two Query Languages?

      • SOQL is used for fetching records based on some parameters or conditions. Example: get the records from a database where the country of the customer is India.
      • Query has some conditions. Table name. We are not doing any random table search. Everything has to be clearly mentioned.
      • SOSL is used for fetching some information from a database. Example: We want to write a code by which we can see records where the word “Peter” is used in the database. Search query will have a text to search.

      dont miss out iconDon’t forget to check out: An Ultimate Guide on How to Import Data in Salesforce

      Aggregate Functions in Salesforce

      • SELECT MAX(Custom_Field__c) FROM Custom_Object__c
      • SELECT MIN(Custom_Field__c) FROM Custom_Object__c
      • SELECT SUM(Custom_Field__c) FROM Custom_Object__c
      • SELECT AVG(Custom_Field__c) FROM Custom_Object__c

      Differences Between SOQL & SOSL

      • As the name suggests, SOSL is an object search language. This will search for some phrases or words for making developers find any record or data.
      • SOSL can search for something only in name, phone, email fields. Example: Something present in number, picklist or currency, we cannot search, means, if our data is present in the field of type name/phone/email, then only we can do searching.
      • Using SOSL we can make queries on many objects at a time.
      • We can query only on fields having type name, phone or email.
      • Using SOQL, we can make queries only on one object at a time.
      • We can query on all fields of any data type.

      Joins in Salesforce

      Salesforce does not support joins, where we can fire/call one query on multiple objects and get data, the way we can do in oracle, SQL etc.

      Salesforce provides an alternate solution for this, which is called ‘Relationship queries’. This means those objects which are having relationships, we can fire “join like query” on them. They must be in relation.

      dont miss out iconCheck out another amazing blog by Romil here: Triggers in Salesforce – Get Started

      DML Statements

      DML statements are called Data Manipulation Language. We can make changes in the database and commit the same by using statements like Insert-Update-Delete.

      DML statements are so essential, that without this you can not make any changes to records in the database

      By using Database queries like SOQL/SOSL, we can only fetch data. They won’t help with making changes in data.