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
vinita kumari 8vinita kumari 8 

Error: Compile Error: A method was found with too much code.

Hi,

I am getting below error while trying to Save a Trigger.

Error: Compile Error: A method was found with too much code. Please consider splitting methods with a lot of code into mulitiple methods. at line -1 column -1

I have checked all methods line which are good to go with. I have also commented all the methods of the trigger.
But still getting this error when I try to add even a single System.debug('==='); line in the code.

Please help me recticy this issue.
NagendraNagendra (Salesforce Developers) 
Hi Vinita,

It seems to be syntax error check for well-formed parenthesis or curly braces. At most 1 million characters you can have in your trigger. 

Regards,
Nagendra.
vinita kumari 8vinita kumari 8
Hi Nagendra,

Thanks for replying!
I have already checked the character count and for syntax error what can be wrong in adding a system.debug(); line.
NagendraNagendra (Salesforce Developers) 
Hi Vinita,

May I request you to please post the code snippet or do let us know where exactly you are writing the System.debug method in your code.

Because you can use System.debug statements only in methods of a class.

For example, see below sample code:

Invalid System.debug:
I need to get the email of the logged in user. For that i wrote this code:
ID usrid = UserInfo.getUserId();
List<User> cusr = [Select Email From User where id =: usrid ];
String uEmail = cusr[0].Email;
System.debug(uEmail);
Valid System.debug:
public constructorforClass()
   {
    cusr = [Select Email From User  where id =: usrid Limit 1];
    uEmail = cusr.Email;
     contmap = new Map<id,contact>([Select id,name from contact where EmailAddress__c = :uEmail]);
    
    
    System.debug(uEmail); 
   }
Hope this helps.

Regards,
Nagendra.