+ Start a Discussion
Naznin VhoraNaznin Vhora 

Error is : Upsert failed. First exception on row 0 with id a0A7F000001qaeRUAQ; first error: MISSING_ARGUMENT, Number__c not specified: [].

Hi All,
I am facing one error while executing the following code.
Please give your suggestion to combat this error and improve my code.
Note : Error is mentioned in Title.
public class Apex_DML 
{
     public void upsertData() // Insert and Update in One Call
        {
                Demo__c[] dl=[select name from Demo__c where Number__c=3]; //Existing Record Fetched
        
                for(Demo__c t:dl)
                {
                        t.Name='Lion'; // Existing Record Updated
                 }        
     
               Demo__c nd=new Demo__c(Name='TrailHead',Number__c=10); // New record Created        
                 dl.add(nd);
        
                try
                {
                         upsert dl Number__c;
                }
                catch(DmlException e)
                {
                        System.debug(e.getMessage());
                }
       
                System.debug('Record Upserted..');        
        
        }
}

 
Best Answer chosen by Naznin Vhora
Aslam ChaudharyAslam Chaudhary
Please select the Number__c in your query.