You need to sign in to do that
Don't have an account?
DIVYANSHU BHUSHAN
Invalid Cross reference key
try{ con2=[select Contact_Role__c from Contact where id = :app.Student_Alumni_Name__c]; system.debug('con2---->'+con2); // Check to see if contact roll is null if(con2.Contact_Role__c == NULL) { con.Contact_Role__c = 'Applicant'; } else { boolean applicantFound = false; string[] contactRoleList = con2.Contact_Role__c.split(';',0); for(String contactRole : contactRoleList) { if(contactRole == 'Applicant') { applicantFound = true; } } if(applicantFound==false) { con.Contact_Role__c = con.Contact_Role__c+'; Applicant'; } } update con; }catch(System.DmlException e){ system.debug(LoggingLevel.INFO, 'Contact save failed - ' + e.getMessage() + ',' + e.getLineNumber()); ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'An unexpected error has occurred saving your application: ' + e.getLineNumber() + ',' + e.getMessage()));
I have this code in my apex class. here app is another object's reference.
While running the code, I am getting this error
"first error: INVALID_CROSS_REFERENCE_KEY, Can not select a person account: [AccountId]".
What shuld I do to remove this error. Thanks in advance. Any help much be appreciated.
pcon
What is the type for the field app.Student_Alumni_Name__c based on the name it looks like that is a text field. Also, where are you getting this error? On line 32 where you update the contact or line 2 where you select the contact?