You need to sign in to do that
Don't have an account?
Lisa Schutter
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, entity type cannot be inserted: Person Account: []
Hi All, Hope someone can help me. After the sandbox refresh I am running a script to update accounts. It works for all my objects, but Person Accounts. Does anyone have any Idea how to fix it?
This is the error that is shown in the last line of my debug:
This is my apex class:
This is the error that is shown in the last line of my debug:
EXCEPTION_THROWN|[47]|System.DmlException: Insert failed. First exception on row 2; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, entity type cannot be inserted: Person Account: []
This is my apex class:
global class sandboxRefreshScript implements SandboxPostCopy{ global void runApexClass(SandboxContext context) { List<Account> accounts = new List<Account>(); Account a1 = new Account(); a1.Name = 'J&T Autolease'; a1.Ownerid = '005w0000005bvNR'; a1.Type = 'LeaseCo'; a1.Status__c = 'Partner'; a1.Phone = '013 820 07 00'; a1.BillingStreet = 'Kraaivenstraat 4'; a1.BillingCity = 'Tilburg'; a1.BillingPostalCode = '5048 AB'; a1.BillingState = 'Zuid-Holland'; a1.ShippingStreet = 'Kraaivenstraat 4'; a1.ShippingCity = 'Tilburg'; a1.ShippingPostalCode = '5048 AB'; a1.ShippingState = 'Zuid-Holland'; accounts.add(a1); Account a2 = new Account(); a2.Name = 'Adler'; a2.Ownerid = '005w0000006WaIF'; a2.BillingCountry = 'Netherlands'; a2.ShippingCountry = 'Germany'; accounts.add(a2); Account a3 = new Account(); a3.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Person Account').getRecordTypeId(); a3.Status__c = 'Customer'; a3.OwnerId = '005w0000004Sz1E'; a3.Salutation = 'Mr.'; a3.FirstName = 'Trafineo'; a3.LastName = 'Trafineo'; a3.PersonEmail = 'settlement+trafineo@thenewmotion.com'; a3.PersonMailingCity = 'Bochum'; a3.PersonMailingStreet = 'Wittener Straße 56'; a3.PersonMailingPostalCode = '44789'; a3.PersonMailingCountry = 'Germany'; a3.hidden_email__c = 'settlement+trafineo@thenewmotion.com'; accounts.add(a3); insert Accounts; List<Contact> contacts = new List<Contact>(); Contact b1 = new Contact(); b1.Salutation = 'Mr.'; b1.FirstName = 'Arjen'; b1.LastName = 'Butter'; b1.Email = 'c.leusink@newmotion.com'; b1.Accountid = a1.ID; contacts.add(b1); insert Contacts; List<Opportunity> opportunities = new List<Opportunity>(); Opportunity c1 = new Opportunity(); c1.Name = 'Zonnestraal'; c1.Ownerid = '005w0000005bvM4'; c1.StageName = 'Intake'; c1.Accountid = a1.ID; opportunities.add(c1); insert Opportunities; List<Payment_Account__c> paymentaccounts = new List<Payment_Account__c>(); Payment_Account__c d1 = new Payment_Account__c(); d1.Name = 'J&T Autolease*'; d1.Ownerid = '005w0000005bvM4'; d1.Billing_Name__c = 'Financiele administratie'; d1.Billing_Email__c = 'l.schutter@newmotion.com'; d1.Payment_Terms__c = '30'; d1.Billing_Address__c = 'Postbus 2094'; d1.Billing_PostalCode__c = '5001 CB'; d1.Billing_City__c = 'Tilburg'; d1.Billing_Country__c = 'NL'; d1.Account__c = a1.Id; paymentaccounts.add(d1); insert paymentaccounts; } }
Is this Account record type assigned to your user's profile?
"I am running a script to update accounts." you run this script with you own user (admin?)
Before you begin, make sure to:
From the object management settings for person accounts, go to Record Types.
- Assign person account record types to profiles that require person accounts.
https://help.salesforce.com/articleView?id=account_person_enable.htm&type=0Regards
Thank you for your awser, we have Person Accounts set up and I am running the script from my account (admin).
Also checked the profil settings to be sure, but they seem fine. Do you have any idea what could be the solution?
1) Could you show the record type settings of your profile like below?
2) CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY is a scourge of SF (the real reason is sometimes very hard to find).
Have you got some triggers on you account (insert)? (recursive trigger, a bad conception of your code)
Regards
This is our Account trigger:
You have already the assigned recordtype "Person Account" for your profile (we don't see the name of the profile nevertheless but if it is yours, it is ok). You could disable "Enhanced Profile User Interface" for the same display (not necessary) ( setup > user interface)
2) AccountUtil.entry(new TriggerParams(trigger.isBefore, trigger.isAfter, trigger.isInsert, trigger.isUpdate, trigger.isDelete, trigger.isUndelete, trigger.new, trigger.old, trigger.newMap, trigger.oldMap));
It is the new format of a generic trigger and the code is in AccountUtil, in the static method entry, we could verify the code for the "after insert".
This is the account util at the moment, where i am puttin it?:
You have to verify your rights for each field of the request. Perhaps one field is not visible for you.
1) Copy paste the code above in the anonymous window ( CTRL + E ) of the Developer Console and "Execute Highlighted"
2) Verify the debug logs generated (double click) in the tab "Logs" (many processes could have been activated when you create or update an account not just the triggers but flows, workflows (process builders), validation rules, and so on)
3) SELECT id FROM user WHERE Id = '005w0000004Sz1E';
Regards
I am receiving this error when I am pressing the button (before logs). But I think this might be because I am doing this in the production area.
In the sandbox I am receiving:
a3.OwnerId = '005w0000004Sz1E';
Regards
This is what I find. What to do next? :)
SELECT id , LastName , FirstName , RecordType.Name
FROM account
WHERE PersonEmail = 'settlement+trafineo@thenewmotion.com';
or
SELECT id,LastName,FirstName
FROM account
WHERE RecordType.Name = 'Person Account'
so you have all the rights
Regards
How do you launch the script? "I am running a script"
Regards
When refresh or create a sandbox I indicate this apex class.
https://releasenotes.docs.salesforce.com/en-us/spring16/release-notes/rn_deployment_sandbox_postcopy_script.htm