6

When calling getDescribe() on a custom field I get the field data.

Although, I need to know when the field is Text Area (Long), Text Area (Rich) or just TextArea.

When seeing the result from salesforce all of them have the same type TextArea without difference between each other.

Is that how it should work?

Is there a way I can differ between those three field types?

1 Answer 1

11

Looks like theres 3 methods you can use to check the definition of a textarea:

  1. field.getType() == Schema.DisplayType.TEXTAREA
  2. field.isHtmlFormatted()
  3. field.getLength()

Here's a snippet of these methods in use:

if (field.getType() == Schema.DisplayType.TEXTAREA) {
    if (field.getLength() <= 255 && !field.isHtmlFormatted()) {
        return 'TextArea';
    } else if ((field.getLength() >= 256 && field.getLength() <= 131072) && !field.isHtmlFormatted()) {
        return 'TextArea (Long)';
    } else if ((field.getLength() >= 256 && field.getLength() <= 131072) && field.isHtmlFormatted()) {
        return 'TextArea (Rich)';
    }
}

You must log in to answer this question.

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