Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Unable to insert record in Person Account SalesForce

Writer Matthew Martinez

I have activated Person Account and try to insert record with the help of APEX. Here is my code

Account pAccount = new Account();
pAccount.recordTypeId = '012370000009dFh';
pAccount.FirstName = 'SFDC';
pAccount.LastName = 'Axel';
pAccount.personEmail = '[email protected]';
insert pAccount;
return 'Added'; 

But when I try to run this code following error displayed:

Error: call to URL failed with status 500, response [{"errorCode":"APEX_ERROR","message":"System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, entity type cannot be inserted: Person Account: []\n\nClass.RESTCaseController.createNewCase: line 22, column 1"}], curl_error , curl_errno 0

(There is no validation issue.) Please help me

1 Answer

The "Standard Record Type Settings" on the Force.com Site have to be changed to the recordtype you require for the Account object. There is no need to them specify the recordTypeID in the insert statement.

Also Ensure that the user has the appropriate access to all modules.

Ash

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.