I am trying to get the character limit for a long text area. So for example I have a custom field called --> My_Text_area__c which has the char limit set as 5000.

So how can I get this value in my apex code. I am using this code to get all the long text area fields -->

Schema.SObjectField field = MapofField.get(fieldName);
Schema.DescribeFieldResult F = field.getDescribe();
if(F.getType() == Schema.DisplayType.TextArea && !field.getDescribe().isFilterable()){
    // get value here and do some logic
  • 2
    Have you checked getLength() method of Schema.DescribeFieldResult?
    – metasync
    Commented May 17, 2022 at 20:17
  • 2
    @metasync - that is the answer and should be posted as such
    – cropredy
    Commented May 17, 2022 at 21:19

1 Answer 1


getLength() method of Schema.DescribeFieldResult returns the length.

For ex.,

Schema.DescribeFieldResult field = Account.Description.getDescribe();



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .