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
AK_SmithAK_Smith 

Error Initial term of field expression must be a concrete SObject

Hello!
Please help me to fix an error in my code
 
global class UpdateAct Implements Schedulable
    {
        global void execute(SchedulableContext sc)
        {
            doexecute();
        }

        public void doexecute()
        {
            list<CTPHARMA__Activity__c> AllRecords = new list<CTPHARMA__Activity__c>();
            AllRecords = [select Id  from CTPHARMA__Activity__c where Id = 'a028E000003U83o'];
            
            if (!allRecords.isEmpty) {
             for (CTPHARMA__Activity__c pg : allRecords){
              pg.RecordTypeId = '012b00000004hic';
                 }
            
            
            update AllRecords;
        }
    }
    }

 
Lokesh KumarLokesh Kumar
HI Smith,

You are missing field RecordTypeId in SOQL Query.
 Use the below-updated code and let me know if it works for you.
global class UpdateAct Implements Schedulable
    {
        global void execute(SchedulableContext sc)
        {
            doexecute();
        }

        public void doexecute()
        {
            list<CTPHARMA__Activity__c> AllRecords = new list<CTPHARMA__Activity__c>();
            AllRecords = [select Id,RecordTypeId   from CTPHARMA__Activity__c where Id = 'a028E000003U83o'];
            
            if (!allRecords.isEmpty) {
             for (CTPHARMA__Activity__c pg : allRecords){
              pg.RecordTypeId = '012b00000004hic';
                 }
            
            
            update AllRecords;
        }
    }
    }

Thanks
Lokesh
Harshit Garg 6Harshit Garg 6
HI AK,
 
global class UpdateAct Implements Schedulable
    {
        global void execute(SchedulableContext sc)
        {
            doexecute();
        }

        public void doexecute()
        {
            list<CTPHARMA__Activity__c> AllRecords = new list<CTPHARMA__Activity__c>();
            AllRecords = [select Id ,RecordTypeId from CTPHARMA__Activity__c where Id = 'a028E000003U83o'];
            
            if (!allRecords[0].isEmpty) {
             for (CTPHARMA__Activity__c pg : allRecords)
			 {
              pg.RecordTypeId = Schema.SObjectType.CTPHARMA__Activity__c.getRecordTypeInfosById().get('012b00000004hic').getRecordTypeId();
             }
            
            
            update AllRecords;
        }
    }
    }

Thanks,
Harshit garg