You need to sign in to do that
Don't have an account?
Federico Larsen
Metadata API error for PersonAccount
Hi all,
When doing a describe metadata, api returns PersonAccount and Account recordtypes mixed all together.
for example (and can be verified with the https://workbench.developerforce.com):
a normal account recordType will return:
fileName: objects/Account.object
fullName: Account.School
type: RecordType
a person account recordtype
fileName: objects/Account.object
fullName: Account.Professor
type: RecordType
therefore, using this information to create a Package.xml for the person account recordType will fail saying:
[sf:retrieve] package.xml - Entity of type 'RecordType' named 'Account.Professor' cannot be found
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Account.Professor</members>
<name>RecordType</name>
</types>
<version>30.0</version>
</Package>
the same for the normal account will work and xml will be downlaoded under objects/Account.object
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Account.School</members>
<name>RecordType</name>
</types>
<version>30.0</version>
</Package>
Now, the right way to deploy the personAccount record type is:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>PersonAccount.Professor</members>
<name>RecordType</name>
</types>
<version>30.0</version>
</Package>
this will work and xml will be downlaoded under objects/PersonAccount.object
How can I know if an account recordtype is for Person or Business account, so I can build correctly the Package.xml ?
Thanks for your help in advance.
When doing a describe metadata, api returns PersonAccount and Account recordtypes mixed all together.
for example (and can be verified with the https://workbench.developerforce.com):
a normal account recordType will return:
fileName: objects/Account.object
fullName: Account.School
type: RecordType
a person account recordtype
fileName: objects/Account.object
fullName: Account.Professor
type: RecordType
therefore, using this information to create a Package.xml for the person account recordType will fail saying:
[sf:retrieve] package.xml - Entity of type 'RecordType' named 'Account.Professor' cannot be found
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Account.Professor</members>
<name>RecordType</name>
</types>
<version>30.0</version>
</Package>
the same for the normal account will work and xml will be downlaoded under objects/Account.object
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Account.School</members>
<name>RecordType</name>
</types>
<version>30.0</version>
</Package>
Now, the right way to deploy the personAccount record type is:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>PersonAccount.Professor</members>
<name>RecordType</name>
</types>
<version>30.0</version>
</Package>
this will work and xml will be downlaoded under objects/PersonAccount.object
How can I know if an account recordtype is for Person or Business account, so I can build correctly the Package.xml ?
Thanks for your help in advance.
The Person Account is just an add on of existing Account object and you can have many recordtypes for Person Account and Account.
How does the system knows which recordtype is for PersonAccount and Account, it uses different relationship to access it.
For business account, you can use RecordTypeId directly to get the recordtype name. For person account, you will need to use RecordType.name and recordType.id. But with this method, you will not get the same name of account type name as business account.
How can you tell which recordtype is for PersonAccount? From recordtype object, there is a field called IsPersonType, this field determines whether the recordtype is PersonAccount or not.
I hope this helps.
Please mark this as a "Best Answer" if this has resolved your issue
All Answers
The Person Account is just an add on of existing Account object and you can have many recordtypes for Person Account and Account.
How does the system knows which recordtype is for PersonAccount and Account, it uses different relationship to access it.
For business account, you can use RecordTypeId directly to get the recordtype name. For person account, you will need to use RecordType.name and recordType.id. But with this method, you will not get the same name of account type name as business account.
How can you tell which recordtype is for PersonAccount? From recordtype object, there is a field called IsPersonType, this field determines whether the recordtype is PersonAccount or not.
I hope this helps.
Please mark this as a "Best Answer" if this has resolved your issue
With this information I was able to skip the problem.
What I do is first query the recordtypes for person accounts:
select Id,Name from RecordType where isPersonType = true and SobjectType='Account'
Bear in mind that this query could fail on Organization without Person Account enabled, and finally, rename/ammend the metadata information coming from the metadata api, replacing for example: Account.Professor with PersonAccount.Professor
Thanks a lot!