0
list<Temp_Invoice__c>  tempInvoice = [select id,First_Name__c,Last_Name__c,Email__c from Temp_Invoice__c limit 1];
 tempInvoice.First_Name__c = billing.billingfirstname;

getting error as Initial term of field expression must be a concrete SObject:List

  • 1
    Based on your comments to the answers given, I think it may be useful if you elaborate your question. What are you trying to do ? Current query won't guarantee you to predict which record is returned, are you sure you aren't simply in need of a new Temp_Invoice__c object instance ? – Samuel De Rycke Nov 15 '12 at 12:52
2

if you're assigning to a list of invoices, you should be consistent ;)

list<Temp_Invoice__c>  tempInvoice = [select id,First_Name__c,Last_Name__c,Email__c from Temp_Invoice__c limit 1];
if(!tempInvoice.isEmpty()){
    tempInvoice[0].First_Name__c = billing.billingfirstname;
}

Note the [0]

  • You would want to check that the list isn't empty before doing that. – Samuel De Rycke Nov 15 '12 at 12:26
  • then getting error as System.ListException: List index out of bounds: 0 Error is in expression '{!save}' in component <apex:page> – Eagerin Sf Nov 15 '12 at 12:26
  • my list will be empty as it has no values in it – Eagerin Sf Nov 15 '12 at 12:27
0

tempInvoice is a list<Temp_Invoice__c>, so if you need information from a specific member of that list, you need to identify which member you want, possibly through square brackets. This is true even if you happen to know that there is only one member in the list. For example:

tempInvoice[0].First_Name__c = billing.billingfirstname;
  • then getting error as System.ListException: List index out of bounds: 0 Error is in expression '{!save}' in component <apex:page> – Eagerin Sf Nov 15 '12 at 12:46
  • That means there were no records returned from your query, and so the list is empty. What to do next depends on what you are trying to do. If you can add more detail to your Question that describes your goals, we can help better. – Jeremy Nottingham Nov 15 '12 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.