Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to resolve this error - invalid_cross_reference_key?

Asked by Aashish Chaursiya Apr 26, 2023 1.2K views 1 answer
Share

About this question

Created a VF page to create Opportunity. While saving the Opportunity on Page it is throwing an exception on Account lookup Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

How to resolve this issue ? can anyone please help me
Here is my class:
public class oppcreate
{
    public Opportunity opp{get; set;}
    public oppcreate ()
    {
        opp= new opportunity();
    }
    public void Saveto(){
        opportunity oppRec= new opportunity();
        oppRec.AccountId= opp.AccountID; // throwing exception on this line
        oppRec.name= opp.name;
        oppRec.closedate= opp.closedate;
        insert oppRec;
    }
}
VF Page:
 
    
    
    
    
    
    
    
    
    
    
    
    
    

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.