You need to sign in to do that
Don't have an account?

Apex equivalent of API call describeSObject - Trying to find length of a custom Text field.
Is there an Apex equivalent of the API call describeSObject?
Since API 15.0 moving a string to the target string that is longer than the target string's length causes an error.
I'd like to discover the target string's length in advance to I can move a substring of the original string and avoid the error. i.e.
integer i = /** code here to discover length of targetString__c **/; myCustomObj__c.targetString__c = Left('Some really long string value for targetString__c', i );
Took a bit of digging but I answered my own question. Substitute your own values for CustObj__c and CustField__c.
:smileyvery-happy:
integer fieldLength = Schema.SObjectType.CustObj__c.fields.CustField__c.getLength();