Define a Custom Big Object:
You can define custom big objects with Metadata API or in Setup. After you define and deploy a big object, you can view it or add fields in Setup. After you’ve deployed a big object, you can’t edit or delete the index. To change the index, start over with a new big object. To define a big object in Setup, see Salesforce Help.
You can define custom big objects with Metadata API or in Setup. After you define and deploy a big object, you can view it or add fields in Setup. After you’ve deployed a big object, you can’t edit or delete the index. To change the index, start over with a new big object. To define a big object in Setup, see Salesforce Help.
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.
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.
Populate a Custom Big Object:
Use Salesforce APIs to populate a custom big object.
You can use a CSV file to load data into a custom big object via Bulk API. The first row in the CSV file must contain the field labels used to map the CSV data to the fields in the custom big object during import.
Re-inserting a record with the same index but different data results in behavior similar to an upsert operation. If a record with the index exists, the insert overwrites the index values with the new data. Insertion is idempotent, so inserting data that already exists won't result in duplicates. Reinserting is helpful when uploading millions of records. If an error occurs, the reinsert reuploads the failed uploads without duplicate data. During the reinsertion, if no record exists for the provided index, a new record is inserted.
For example, this CSV file contains data for import into a Customer Interaction big object.
Play Start,In-Game Purchase,Level Achieved,Lives Used,Platform,Play Stop,Score,Account 2015-01-01T23:01:01Z,A12569,57,7,PC,2015-01-02T02:27:01Z,55736,001R000000302D3 2015-01-03T13:22:01Z,B78945,58,7,PC,2015-01-03T15:47:01Z,61209,001R000000302D3 2015-01-04T15:16:01Z,D12156,43,5,iOS,2015-01-04T16:55:01Z,36148,001R000000302D3
Populate a Custom Big Object with Apex
Use Apex to populate a custom big object.You can create and update custom big object records in Apex using the insertImmediate method.Reinserting a record with the same index but different data results in behavior similar to an upsert operation. If a record with the index exists, the insert overwrites the index values with the new data. Insertion is idempotent, so inserting data that exists doesn’t result in duplicates.Here is an example of an insert operation in Apex that assumes a table in which the index consists of FirstName__c, LastName__c, and Address__c.// Define the record. PhoneBook__b pb = new PhoneBook__b(); pb.FirstName__c = 'John'; pb.LastName__c = 'Smith'; pb.Address__c = '1 Market St'; pb.PhoneNumber__c = '555-1212'; database.insertImmediate(pb); // A single record will be created in the big object.---------------------------// Define the record with the same index values but different phone number. PhoneBook__b pb = new PhoneBook__b(); pb.FirstName__c = 'John'; pb.LastName__c = 'Smith'; pb.Address__c = '1 Market St'; pb.PhoneNumber__c = '415-555-1212'; database.insertImmediate(pb); // The existing records will be "re-inserted". Only a single record will remain in the big object.------------------------------// Define the record with the different index values and different phone number PhoneBook__b pb = new PhoneBook__b(); pb.FirstName__c = 'John'; pb.LastName__c = 'Smith'; pb.Address__c = 'Salesforce Tower'; pb.PhoneNumber__c = '415-555-1212'; database.insertImmediate(pb); // A new record will be created leaving two records in the big object.Delete Data in a Custom Big Object
Use Apex or SOAP to delete data in a custom big object.The Apex method deleteImmediate() deletes data in a custom big object. Declare an sObject that contains all the fields in the custom big object’s index. The sObject acts like a template. All rows that match the sObject’s fields and values are deleted. You can specify only fields that are part of the big object’s index. You must specify all fields in the index. You can’t include a partially specified index or non-indexed field, and wildcards aren’t supported.In this example, Account__c, Game_Platform__c, and Play_Date__c are part of the custom big object’s index. When specifying specific values after the WHERE clause, fields must be listed in the order they appear in the index, without any gaps.// Declare sObject using the index of the custom big object --> List<Customer_Interaction__b> cBO = new List<Customer_Interaction__b>(); cBO.addAll([SELECT Account__c, Game_Platform__c, Play_Date__c FROM Customer_Interaction__b WHERE Account__c = '001d000000Ky3xIAB']); Database.deleteImmediate(cBO);
Comments
Post a Comment