0

I'm trying to write some standard Contact's fields e.g. MobilePhone and Email (I'm new to this object), when I create a new PersonAccount.

For example using an Anonymous window I tried with this code:

Account acc = new Account(FirstName='User', 
                         LastName= 'System',
                         MobilePhone=33900000,
                         Email = 'a@a.com'
);
insert acc;

I receive this error: "Field does not exist: MobilePhone on Account".

How is possible to write standard Contacts's field when creating a PersonAccount?

0

You use the Person fields:

Account acc = new Account(FirstName='User', 
                         LastName= 'System',
                         PersonMobilePhone='33900000',
                         PersonEmail = 'a@a.com'
);
insert acc;
2
  • Thank you! In general, Can I access Contact's standard fields? e.g. Description, Salutation...or any other standard field? – sdfcwolf Apr 24 '20 at 12:37
  • @sdfcwolf I believe you can access most, if not all, the standard fields, plus you can access any custom field (use CustomField__pc instead of CustomField__c). – sfdcfox Apr 24 '20 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.