In a managed package i am trying to create an account record. There are org which use recordtypes and some orgs dont use recordtypes. So we have a setting which defines the recordtype needs to be associated with the account.
Here is the code i am using
if(String.isBlank(CS.Account_Default_Record_type__c) || Schema.SObjectType.Account.getRecordTypeInfosByName().size() > 1)
{
account ac = new Account(name ='Storage Account');
insert ac;
}
else
{
account ac = new Account(name ='Storage Account', recordtypeid = CS.CMFSH__Account_Default_Record_type__c );
insert ac;
}
My dev env does not have recordtype for Account so it does give an error
Field does not exist: recordtypeid on Account
If i do enable recordtype this error should go off.
My question is, Would there be an error when we try install the app in an org which doesnt have recordtype enabled for account?
Is there a way we can assign value to field without using account.recordtypeid explicitly.