• Dongzhi Yang
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,
I have the following code which runs correct from a workspace in developer console. However,  when i put them into a test class, the same code return the List Index Out Of Bounds Error. It is as if in a test class , no records can be retrieved. 
Anyone who has the same experience? would appreciate very much for a solution
---------------------------------------------------------------
List<Warehouse_Transaction__c> w = [SELECT Name FROM Warehouse_Transaction__c WHERE Name = :'INV-0000'];
        List<Merchandise__c> m = [SELECT Name FROM Merchandise__c WHERE Name = :'M-00010'];
        system.debug(w[0].Name);
        system.debug(m[0].Name);
Hi,
I have the following code which runs correct from a workspace in developer console. However,  when i put them into a test class, the same code return the List Index Out Of Bounds Error. It is as if in a test class , no records can be retrieved. 
Anyone who has the same experience? would appreciate very much for a solution
---------------------------------------------------------------
List<Warehouse_Transaction__c> w = [SELECT Name FROM Warehouse_Transaction__c WHERE Name = :'INV-0000'];
        List<Merchandise__c> m = [SELECT Name FROM Merchandise__c WHERE Name = :'M-00010'];
        system.debug(w[0].Name);
        system.debug(m[0].Name);

Hi,

 

 

LIST<Account> Alist=[SELECT id,name,(SELECT contact.FirstName,Contact.Lastname FROM account.contacts) FROM account
                     Where industry='environmental'];

System.debug('The Account Details:'+Alist[0]);
System.debug('The Account Name is:'+Alist[0].Name);
System.debug('The Associated Contact FirstName is:'+Alist[0].contact.FirstName);

In the above code through a error:Invalid foreign key relationship: Account.contact

 

it is Parent to child retrieve single record.

 

Thanks

Ramesh

 

 

  • November 22, 2013
  • Like
  • 0