neither one works.
the wrong way, with a loop looks like this.// First get the new invoice statementinteger 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: 14Variable does not exist: inv.idi am too confused to write the syntax with a list. and could use some help.
3 risposte
Hi Howard, Please use the below code syntax as per your requirement :
integer i = 0;
for (invoice_statement__c inv : [SELECT id FROM Invoice_Statement__c WHERE Description__c = 'My new invoice']){
system.debug(inv.id );
}
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