
Big Objects – Works against Org Data Storage Limits
minutes read
Big objects is a new type of object that Salesforce provides. Big objects do not count against the storage limit. They let you store and manage large amounts of data.
Types of big objects:
- Standard big objects: Standard big objects include FieldHistoryArchive and is part of the Field Audit Trail product. This provides storage for up to ten years of archived field history data. It is useful to organizations that must comply with industry regulations related to auditing and data retention.
- Custom big objects: Salesforce users can also create custom big objects by defining and deploying them through the Metadata API. To define a custom big object, users need to simply create an object file that contains the following:
- Index (determined the big object’s identity and its ability to be queried)
- Permission set (to define the permissions for each field)
- Package file (to define the contents of the object metadata)
Supported Data Types:
- DateTime
- Lookup
- Number
- Text
- Long
- TextAreafieldtypes
Supported Features:
- Big objects work with Visualforce pages or Lightning Components.
- Can be used for data security and access support objects and field permissions.
- Can be used in Einstein Analytics, but not for report builder.
- Big objects can be included in managed packages.
Unsupported Features:
- Big objects cannot be used in triggers, flows, processes, Salesforce apps or standard UI.
- We cannot track Field history on big objects.
Limitations :
- Organizations have a maximum number of 100 big objects.
- Can be used in Einstein Analytics, but not for report builder.
Define a custom big object
We define a custom big object through the Metadata API by creating XML files that contain its definition, fields, and index. When working with big objects, users must use the Metadata API to define a big object or add a field to make it custom. You cannot make changes to the data in big object; however, you can make a copy with different data. Also, big objects do not support sharing rules.
- object files—Create a file for each object to define the custom big object, its fields, and its index.
- permissionset/profile files—Create a permissionSet or profile file to specify permissions for each field. These files are required to grant access to users. By default, access to a custom big object is restricted.
- package file—Create a file for the metadata package to specify the contents.
How to create a big object?
Big object cannot do it in a declarative way. You need to define them via Metadata API and then do a deployment via cmd or workbench.There are different ways to create big object record, like using a csv file, use APIs like Bulk API or even Async SOQL.
Create Metadata Files for Deployment
Create metadata files that you can deploy as a package.
object files
<CustomObject xmlns=”http://soap.sforce.com/2006/04/metadata”>
<deploymentStatus>Deployed</deploymentStatus>
<fields>
<fullName>WhatID__c</fullName>
<label>What Id</label>
<length>20</length>
<required>true</required>
<type>Text</type>
<unique>false</unique>
</fields>
<fields>
<fullName>WhatTime__c</fullName>
<label>Time of the Survey</label>
<required>true</required>
<type>DateTime</type>
</fields>
<fields>
<fullName>WhatObject__c</fullName>
<label>What Object</label>
<length>20</length>
<required>false</required>
<type>Text</type>
<unique>false</unique>
</fields>
<fields>
<fullName>Question1__c</fullName>
<label>Question 1</label>
<length>20</length>
<required>false</required>
<type>Text</type>
<unique>false</unique>
</fields>
<fields>
<fullName>Answer1__c</fullName>
<label>Answer 1</label>
<length>100</length>
<required>false</required>
<type>Text</type>
<unique>false</unique>
</fields>
<indexes>
<type>PRIMARY</type>
<fullName>SurveyPK</fullName>
<fields>
<name>WhatID__c</name>
<sortDirection>DESC</sortDirection>
</fields>
<fields>
<name>WhatTime__c</name>
<sortDirection>DESC</sortDirection>
</fields>
</indexes>
<label>Big Survey</label>
<pluralLabel>Big Surveys</pluralLabel>
</CustomObject>
permissionset files
<?xml version=”1.0″ encoding=”UTF-8″?>
<PermissionSet xmlns=”http://soap.sforce.com/2006/04/metadata”>
<description>Survey Big Object PermissionSet</description>
<hasActivationRequired>false</hasActivationRequired>
<label>Survey Big Object PermissionSet</label>
<!–
<fieldPermissions>
<editable>true</editable>
<field>Survey__b.WhatID__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Survey__b.WhatTime__c</field>
<readable>true</readable>
</fieldPermissions>
–>
<fieldPermissions>
<editable>true</editable>
<field>Survey__b.WhatObject__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Survey__b.Question1__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Survey__b.Answer1__c</field>
<readable>true</readable>
</fieldPermissions>
</PermissionSet>
Package file
<Package xmlns=”http://soap.sforce.com/2006/04/metadata”>
<types>
<members>*</members>
<name>CustomObject</name>
</types>
<types>
<members>*</members>
<name>PermissionSet</name>
</types>
<version>40.0</version>
</Package>
Deploy custom big objects as a Metadata Package
Use the Metadata API to deploy a custom big object. We can use different tools, like Workbench or the Force.com Migration Tool, to deploy. When building a package to deploy a custom big object, make sure the object file is in a folder called “objects” and the permissionsetfile is in a folder called “permissionsets”. Package.xml must be in the root directory, and not in a folder within the package.
Run a test deployment by using the checkonly deployment option. In Workbench, select the Check Only option and Single Package on the Deploy screen.
Click on Deploy Button
Status is shown Below
View a custom big object in setup:
After you’ve deployed your custom big object, you can view it by logging in to your organization and, from Setup, entering big objects in the Quick Find box, then selecting big objects
Click the name of a big object, to see its fields and relationships.
Field and Relationships of big object
From here, we can edit the labels and names for your custom big object and its fields. We can also delete a custom big object from Setup. Deleted big objects are stored for 15 days. During that time, you can restore or permanently delete it, but after those 15 days are up, the big object is permanently deleted.