As per doc (https://help.salesforce.com/s/articleView?id=sf.customize_recordtype_considerations.htm&type=5), From the UI, you can change an account’s record type from a business account to a business account or from a person account to a person account. However, to change an account’s record type from a business account to a person account, or vice versa, you must use the API.
If you are using API you can update.
Please mark as Best Answer if above information was helpful.
if you do not have write access to a person account record type, you cannot update that record using Apex. Access to record types is determined by the organization's sharing settings and the user's profile or permission set. If you do not have the necessary permissions to update a record of a specific record type, you would need to either request the required access from your system administrator or contact the person who has the appropriate permissions to make the update for you.
if it helps you please mark it as a best answer, Thanks!
Shivam, Can you elaborate further? Re: I don't have write access of person account recordtype, Can we update the that record in apex?
* Record types don't restrict write access to records, but sharing settings can do that. * Apex in system mode can update the record; Apex "with sharing" cannot if the user cannot update it. * If you mean that you can't select Person Account record type for a new record, that's corrected in your profile or via permission set -- grant access to the Person Account record type. * If it works in one org and not in another, does that other org have person accounts enabled? It's something that must be added to each org by salesforce support (unless my information is outdated). * If you are trying to change a record from some other record type, then Vinay's response is correct.
To change a business account to a person account in code, *IF* there is 1 and only 1 contact:
Id AccountId = '';// you must supply the account Id here
RecordType personRt = [
SELECT Id, Name
FROM RecordType
WHERE SObjectType='Account' and isPersonType=true
LIMIT 1
];
Account a = [
SELECT Id, RecordTypeId, OwnerId, Name
FROM Account
WHERE Id=:accountId
LIMIT 1
];
List<Contact> c = [
SELECT Id, FirstName, LastName, OwnerId
FROM Contact
WHERE AccountId=:a.Id
];
if (c.size()==1) {
if (c[0].OwnerId != a.OwnerId) {
c[0].OwnerId = a.OwnerId;
update(c[0]);
}
Account updacct = new Account(Id=a.Id, RecordTypeId=personRt.Id);
update(updacct);
}
As per doc (https://help.salesforce.com/s/articleView?id=sf.customize_recordtype_considerations.htm&type=5), From the UI, you can change an account’s record type from a business account to a business account or from a person account to a person account. However, to change an account’s record type from a business account to a person account, or vice versa, you must use the API.
If you are using API you can update.
Please mark as Best Answer if above information was helpful.
Thanks,
if you do not have write access to a person account record type, you cannot update that record using Apex. Access to record types is determined by the organization's sharing settings and the user's profile or permission set. If you do not have the necessary permissions to update a record of a specific record type, you would need to either request the required access from your system administrator or contact the person who has the appropriate permissions to make the update for you.
if it helps you please mark it as a best answer,
Thanks!
Re: I don't have write access of person account recordtype, Can we update the that record in apex?
* Record types don't restrict write access to records, but sharing settings can do that.
* Apex in system mode can update the record; Apex "with sharing" cannot if the user cannot update it.
* If you mean that you can't select Person Account record type for a new record, that's corrected in your profile or via permission set -- grant access to the Person Account record type.
* If it works in one org and not in another, does that other org have person accounts enabled? It's something that must be added to each org by salesforce support (unless my information is outdated).
* If you are trying to change a record from some other record type, then Vinay's response is correct.
To change a business account to a person account in code, *IF* there is 1 and only 1 contact: