function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Karan Sampat 64Karan Sampat 64 

unable to add fields via apex to big object

I am able to create a big object , also add fields for it . I have created PermissionSet . 
When i am trying to insert fields via apex , i get error for non indexed field . It shows 'variable doesnt exsit ' , I am able to add values via apex to indexed fields . 

Help will be appreciated .
bhanu_prakashbhanu_prakash
Hi Karan, 
Mark as best answer, If it resloves !!
you cannot add new fields into Big objects, you need to create a field while creation of big object only.

If you are update records try to use insertImmediate , you can do that using apex
// 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.
Check these PDF for more info page no : 14 
https://resources.docs.salesforce.com/214/latest/en-us/sfdc/pdf/big_objects_guide.pdf

Mark as resloved if it helps :) :)
Thanks, 
Bhanu Prakash
visit ForceLearn.com​ (https://www.forcelearn.com)
Karan Sampat 64Karan Sampat 64
Thank you bhanu for the reply I have created a bigobject It has 4 fields 2 of them are indexed , 2 are not indexed When I try to insert via Apex , 2 non indexed field I am unable to insert Can you please help in that scenario
Brian CBrian C
Hi Karan,

Were you able to resolve this? I am having the same issue with my own Big Object.

The Big Object has 10 fields, two of which are indexed. The permission set file has editable on each field set to true. When I attempt to insert records via Apex in the Developer Console, I receive a "Variable not found error". However, I can insert a record which has only the indexed fields populated.

In troubleshooting, I attempted to follow along with the Trailhead module (https://trailhead.salesforce.com/en/content/learn/modules/big_objects/big_objects_define_custom_big_objects) and I receive the same error when working with the test big object.

 
Brian CBrian C
I believe I've figured out the issue. Even though I explicitly listed the fields in the permission set, they were not getting set correctly in Salesforce. However, you can create a permission set with the correct settings and assign it as needed. After assigning the permission set, I was able to insert big object records via Apex.