+ Start a Discussion
GrantMGrantM 

Create Person Account error: bad field names on insert/update call: IsPersonAccount

Hi
 
I am trying to create a person account but am receiving the following error:
bad field names on insert/update call: IsPersonAccount
What is causing this?
I am creating this just like any other object.
 
I am trying to follow your online api example:
But this doesn't seem to be to descriptive as to how to create a person object and states:
"For more information about person accounts, see the Salesforce online help"
Which i find quite strange cause i'm in the Salesforce online help and can't find any other articles reagarding this. (hyperlinking this kind nformation would also be very helpful)
 
Please supply some assistance.
Thank you very much
zakzak
You create a person account by specifying a person account record type for the record.
GrantMGrantM
thanks for your help
WilmerWilmer

Hi, I tried to create a person Account to test a trigger using Apexcode and I specified the recordtypeId corresponding to the one I need. but an error comes up saying "System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: id value not valid for the users profile: 01270000000DT0zAAG: [RecordTypeId]". The point is that I don't understand the reason because I use an administrator profile.

Here is the code:

public class Test_AvoidDuplicate_Accounts {

 static testMethod  void t1() {
  Date b = System.today();
  b = b.addYears(-2);
        String IdPacienteTMA = '01270000000DT0zAAG'; // Patient TMA recordtype ID
        String IdPacienteA = '01270000000DSLlAAO';   // Patient  A recordtype ID
        String IdDireccion = 'a0T7000000AFu4cEAD'; //My Address recordtype ID
        
// Patient TMA       
Account a2 = new Account(RecordTypeId=IdPacienteTMA, IsPersonAccount=true, firstname='Acc0', lastname='Account_PTMA' , Numero_de_Documento__c=942.0);
  insert a2;
  system.debug (a2);


        // Patient TMA
  Account a0 = new Account(IsPersonAccount=true, firstname='Acc0', lastname='Account_PTMA',Tipo_de_Documento__c='DNI' , Numero_de_Documento__c=942.0, RecordTypeId=IdPacienteTMA);
  insert a0;
  system.debug (a0);

  
  
  // Patient A
        Account a1 = new Account(IsPersonAccount=true, firstname='Acc1', lastname='Account_PA',Tipo_de_Documento__c='DNI', Numero_de_Documento__c=942.0, Calle__c='Mi Calle', Numero__c='23', Direccion__c='a0TT0000000CirDMAS', PersonBirthdate= b, RecordTypeId=IdPacienteA);
  insert a1;
  system.debug (a1);
 }
}

SuperfellSuperfell
Even if you're an admin, the recordType still needs mapping into your profile for you to be able to use it.