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
Rizwan Ali 8Rizwan Ali 8 

Create an Apex class with a method that returns an array (or list) of strings.

I got this error:
Line: 12, Column: 1
System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, ID is invalid or you do not have access to the record.: [toAddresses, Your email address]
Best Answer chosen by Rizwan Ali 8
Khan AnasKhan Anas (Salesforce Developers) 
Hi Rizwan,

Greetings to you!

I believe you've forgotten to replace Your email address with your actual email address in the execute anonymous code. You need to replace "Your email address" with a valid email id.

For 'Create an Apex class with a method that returns an array (or list) of strings' challenge you can use below code.
 
public class StringArrayTest {

    public static List<String> generateStringArray(Integer length) {
  
        List<String> myArray = new List<String>();
     
        for(Integer i=0;i<length;i++) {
    
            myArray.add('Test ' + i);
         
            System.debug(myArray[i]);
        } 
        return myArray;
    }   
 }

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Rizwan Ali 8Rizwan Ali 8
Ohhh , I got it 

I have to type my Email Address instead of 'Your email address' in Execute Anonymous Window .
Khan AnasKhan Anas (Salesforce Developers) 
Hi Rizwan,

Greetings to you!

I believe you've forgotten to replace Your email address with your actual email address in the execute anonymous code. You need to replace "Your email address" with a valid email id.

For 'Create an Apex class with a method that returns an array (or list) of strings' challenge you can use below code.
 
public class StringArrayTest {

    public static List<String> generateStringArray(Integer length) {
  
        List<String> myArray = new List<String>();
     
        for(Integer i=0;i<length;i++) {
    
            myArray.add('Test ' + i);
         
            System.debug(myArray[i]);
        } 
        return myArray;
    }   
 }

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer