ABSYZ ABSYZ

  • Home

    Home

  • About us

    Who We Are

  • Our Expertise

    What we Do

  • Our Approach

    How We Do It

  • Products

    What We Made

  • Industries

    Who We Do It For

  • Clients

    Whom We Did It For.

  • Article & Blogs

    What Experts Think

  • Careers

    Join The Team

  • Get In Touch

    Let’s Get Started

ABSYZ

Defining and Inserting Data Into Big Objects

Home / Article & Blogs / Salesforce / Big Objects / Defining and Inserting Data Into Big Objects
By Ankit C inBig Objects, Salesforce
defining and inserting data into big objects

Introduction

Big objects allow us to store and manage large amounts of data in Salesforce. We can extract data from other objects or bring data from external systems and archive them into big objects.

Big objects can store data up to millions or billions of records.

We can create up to 100 big objects in an org.

Big objects are supported in Unlimited, Enterprise, Performance, and Developer editions up to 1 million records. Additional records capacity can be availed as an add-on license.

Defining Big Objects

We can define big objects either using the Metadata API or in the Setup.

To create a new Big Object, go to Setup and search for Big Object in the quick find box. Then click on New and give the name for the big object.

All big objects are suffixed by “__b” at the end of the API Name. Lets consider we have a big object called Orders, the API name will Orders__b.

We can create custom fields of the following types in a big object.

  • Lookup Relationship
  • Date/ Time
  • Email
  • Number
  • Phone
  • Text
  • Text Area (Long)
  • URL

Before we can use the big object, we have to create an Index that will act as a composite primary key. This index will be used for querying and filtering the big object data.

Considerations for creating an Index for a big object

  • Only the required custom fields can be included while creating an index.
  • Up to a maximum of 5 fields can be included in the index.
  • The total character length across all fields included in an Index cannot exceed 100.
  • URL and Long Text Area fields cannot be included in the Index.
  • Once we create an Index, we cannot modify or delete it. If we need to make any modifications we have to delete the big object and create it again.
  • We have to specify the index position in the order in which we want to use the filters in the query. For example, we have to specify the Index position as 1 for the most commonly used filter in the query.

To create an Index, click on New on the Index section and select the custom fields that you want to include in the Index and specify the Index Position and Index Direction and click on Save.

The option to create a new index is only available when you have marked at least one custom field as Required.

Now that we have defined the Index, we can insert data into the Big Object.

Inserting data into Big Object through Apex

We can insert records into the big object using the Database.insertImmediate() method.

Inserting a second record with the same index but different data will be considered as an upsert operation and the data will be overwritten with the new data for that index.

Consider the below example in which we have a big object called Orders__b and an Index which includes the fields Order_Number__c, Status__c, Type__c.

The below code will create a new record in the Orders__b big object with the specified values.

Orders__b order = new Orders__b();
order.Order_Number__c='12345678';
order.Status__c = 'Draft';
order.Type__c = 'Upgrade';
order.Quantity__c = 5;
order.Order_Amount__c = 20000;
database.insertImmediate(order);

Let’s consider we create another record with the same index value but different data.

Orders__b order = new Orders__b();
order.Order_Number__c='12345678';
order.Status__c = 'Draft';
order.Type__c = 'Upgrade';
order.Quantity__c = 10;
order.Order_Amount__c = 35000;
database.insertImmediate(order);

The above code will not insert a new record but it will update the existing data with the new data as the key already exists.

Querying Big Objects

We can query the data in the big objects by building an index query starting from the first field defined in the index.

There must not be any gaps between the first and last field in the query as explained below.

In the Orders__b Big Object, we have Order_Number__c in the 1st position and Status__c and Type__c in the 2nd and 3rd position of the index respectively.

The below query will return the correct data as we have specified all three fields of the index.

SELECT Quantity__c, Order_Number__c, Status__c, Type__c, Order_Start_Date__c, Order_Amount__c FROM Orders__b WHERE Order_Number__c='12345678' AND Status__c='Draft' AND Type__c='Upgrade'

Whereas the below query will throw an error as it has a gap between the first and the last index.

SELECT Quantity__c, Order_Number__c, Status__c, Type__c, Order_Start_Date__c, Order_Amount__c FROM Orders__b WHERE Order_Number__c='12345678' AND Type__c='Upgrade'

Considerations While Querying Big Objects

  • We cannot include the !=, LIKE, NOT IN, EXCLUDES, and INCLUDES operators in the query.
  • Aggregate functions are not allowed.
  • To retrieve a list of records, we must not include the Id field in the query. Including the Id field in the query will return results that have an empty Id.
  • We can use =, <, >, <=, or >=, or IN operators on the last field in your query. Any prior fields in your query can use only the = operator.
Apexbig objectsSalesforceSFDC
187
Like this post
2 Posts
Ankit C

Search Posts

Archives

Categories

Recent posts

Meet OmniStudio – Revolutionize Your Creative Work

Meet OmniStudio – Revolutionize Your Creative Work

BioAsia 2023 in Hyderabad: An Annual International Event

BioAsia 2023 in Hyderabad: An Annual International Event

The Role Of Marketing in Small & Medium Enterprises

The Role Of Marketing in Small & Medium Enterprises

Salesforce For Retail: How Salesforce CRM Can Help Retailers

Salesforce For Retail: How Salesforce CRM Can Help Retailers

What is ChatGPT & How Does It Work?

What is ChatGPT & How Does It Work?

  • Service Cloud for customer delight
    Previous PostService Cloud for customer delight
  • Next PostThe power of Community Cloud
    Service Cloud for customer delight

Related Posts

Meet OmniStudio – Revolutionize Your Creative Work
Salesforce

Meet OmniStudio – Revolutionize Your Creative Work

Salesforce For Retail: How Salesforce CRM Can Help Retailers
Salesforce

Salesforce For Retail: How Salesforce CRM Can Help Retailers

Introduction To Copado Devops Tool
Salesforce

Introduction To Copado Devops Tool

What is Salesforce Code Builder?
Salesforce

What is Salesforce Code Builder?

Leave a Reply (Cancel reply)

Your email address will not be published. Required fields are marked *

*
*

ABSYZ Logo

INDIA | USA | UAE

  • About us
  • Article & Blogs
  • Careers
  • Get In Touch
  • Our Expertise
  • Our Approach
  • Products
  • Industries
  • Clients
  • White Papers

Copyright ©2022 Absyz Inc. All Rights Reserved.

youngsoft
Copy
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “ACCEPT ALL”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent. Privacy Policy
Cookie SettingsREJECT ALLACCEPT ALL
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled

Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.

CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.

Functional

Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.

Performance

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

Analytics

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.

Advertisement

Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.

Others

Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.

SAVE & ACCEPT