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
Ivaylo BalabanovIvaylo Balabanov 

Big Object apex error invalid Type

Hello,

I am trying to update a Big Object, but when I try to use it in method it gives me an error Invalid Type. When I use it in Batch class it is OK.
Just trying to figure out where I can use it and where I cannot.

Regards,
Ivo
mukesh guptamukesh gupta
Hi Ivaylo,

Please follow below code:-

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.

INSERT 
// 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.

UPDATE
// 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.

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
Ivaylo BalabanovIvaylo Balabanov
Hi Mukesh,

Let me show you what i have in mind
 Map<id,Account> accsMap=new Map<id,Account>([select id,MasterRecordId from Account where id in:oldMap.keyset() and masterrecordid<>null ALL ROWS]);
        /*
        List<ClientsMonthlyStatus__b> clMonthly=[Select id,account__c from ClientsMonthlyStatus__b where account__c in:accsMap.keyset()];
        for(ClientsMonthlyStatus__b cm:clMonthly){
            cm.account__c=accsMap.get(cm.account__c).MasterRecordId;
        }
        Database.insertImmediate(cliMonths);
        */
So when I uncoment this I got a message Invalid Type ClientsMonthlyStatus__b

But in this class
public Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator('Select id,Name,Account_Status__c,Date_of_1st_Live_Oppt__c,BillingCountry,Desk__c,Account_Preferred_Language__c from Account where Client__c=1');
    }
    public void execute(
            Database.BatchableContext BC,
            List<Account> scope){
        List<ClientsMonthlyStatus__b> cliMonths=new List<ClientsMonthlyStatus__b>();
        for(Account a:scope){
            ClientsMonthlyStatus__b cm=new ClientsMonthlyStatus__b();
           cm.Account__c=a.id;
           cm.Account_Status__c=a.Account_Status__c;
           cm.Live_Since__c=a.Date_of_1st_Live_Oppt__c;
           cm.Desk__c=a.Desk__c;
           cm.Language__c=a.Account_Preferred_Language__c;
           cm.Billing_Country__c=a.BillingCountry;
           cm.Client_Name__c=a.Name;
           cm.Date__c=system.today();
           cm.UniqueField__c=a.id+String.valueof(system.today().year())+String.valueof(system.today().month());
           cliMonths.add(cm);
        }
        Database.insertImmediate(cliMonths);
    }
    public void finish(Database.BatchableContext BC){
       
    }
It is recognized.
I have tried in other methods. For some it is allowed for some not.
Just trying to figure out what the rules are.

Regards,
Ivo