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
cherialcherial 

Error: Compile Error: Incorrect SObject type: AccountDetails__c should be Account at line 1 column 1

I have created a tab(Custom Object) whose details are:

Singular Label    AccountDetails    
Plural Label    AccountDetails    
Object Name    AccountDetails    
API Name    AccountDetails__c

I created a class and defined a method  addHelloWorld(AccountDetails__c[] accs) and it is saved successfully.

Then i defined a trigger:

trigger helloWorldAccountDetailsTrigger on AccountDetails__c (before insert) {

  AccountDetails__c[] accs = Trigger.new;

   MyHelloWorld.addHelloWorld(accs);
}

While saving the trigger getting an error: Error: Compile Error: Incorrect SObject type: AccountDetails__c should be Account at line 1 column 1

Please any one suggest me how to rectify this error.

Thanks in advance
cheers,
Nath
hisrinuhisrinu
addHelloworld method is the static one or not?
cherialcherial
Thanks sri,

Yes this method is static.
Clearly the complied and saved class is:

public class MyHelloWorld {

   public static void addHelloWorld(AccountDetails__c[] accs){

      for (AccountDetails__c a:accs){
         if (a.Hello__c != 'World') {
            a.Hello__c = 'World';
         }
      }
   }

}



hisrinuhisrinu
First save the class and then save the trigger.
Might be class is not saving properly.
cherialcherial
I finally solved this error.
:smileyvery-happy:

Thanks



MrTikMrTik

I am in a similar situation. How did you solve the error?