You need to sign in to do that
Don't have an account?

i am trying to loop thu an object 2 ways . the wrong way with a lop and the right way with a list
i am trying to loop thu an object 2 ways . the wrong way with a lop and the right way with a list.
neither one works.
the wrong way, with a loop looks like this.
// First get the new invoice statement
integer i = 0;
for (invoice_statement__c[] inv : [SELECT id FROM Invoice_Statement__c]);
{
//WHERE Description__c='My new invoice'];
system.debug(inv.id );
}
i get this error message.
Line: 7, Column: 14
Variable does not exist: inv.id
i am too confused to write the syntax with a list. and could use some help.
neither one works.
the wrong way, with a loop looks like this.
// First get the new invoice statement
integer i = 0;
for (invoice_statement__c[] inv : [SELECT id FROM Invoice_Statement__c]);
{
//WHERE Description__c='My new invoice'];
system.debug(inv.id );
}
i get this error message.
Line: 7, Column: 14
Variable does not exist: inv.id
i am too confused to write the syntax with a list. and could use some help.
you need interate thtought list, becouse inv it's invoice_statement__c[] - list.
try this
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks,
Alex
Please give this a try and let me know:
Thanks,
Shyama
Please use the below code syntax as per your requirement : The query will return records in chunk and assign a single instance of it to the "inv" varibale.
Now you can use this inv varibale to perform action on the record.
Let me know if you need more help on this.
Thanks,
Abhishek