Loading

DescribeFieldResult.getLength() returns maximum of 40 characters for longer API name

Data pubblicazione: Oct 13, 2022
Descrizione
The current character limit for creating field names and labels is 40 characters. However an object name can be much longer if it has a namespaceprefix. When using the DescribeFieldResult.getLength() you will see maximum of 40 characters even if the API name is longer. 
Risoluzione
When you create a Custom Object that is 40 characters , "__c" is suffixed that makes it 43 char.
The max length of a namespace prefix is 15, then the double underscore, then the object name, so 15 + 2 + 43. The true length of this field is really 60.

Note that, although the actual field length could be greater than 40, DescribeFieldResult.getLength() will still return 40 as maximum size of the field.

Example:
 
API NamelengthgetLength()
FinancialServicesCloud__Balance_Sheets_From_Previous_Years__c6140
FinancialServicesCloud__Account_Revenue_Forecast__c5140
FinancialServicesCloud__Accounts_Payable_Subsidiary_Ledger__c6140

DescribeFieldResult.getLength()   Returns the maximum size of the field for the DescribeFieldResult object in Unicode characters (not bytes).
Numero articolo Knowledge

000381913

 
Caricamento
Salesforce Help | Article