How to Get the Length of a Standard Field in Salesforce?

#1MinuteTip MuleSoft Here is how you can get a standard field’s length in Salesforce. There are other mechanisms too, but this one will probably be the simplest.

1. Click on Gear icon -> Right click on Developer Console -> Click Open Link in New Tab

Click on Gear icon -> Right click on Developer Console -> Click Open Link in New Tab

2. Click on Debug -> Open Execute Anonymous Window

In Developer Console Window, click on Debug -> Open Execute Anonymous Window

3. Type the following command, check Open Log and click Execute. Replace the highlighted part of the code with the API name of the object and field that you want to get the length of.

System.Debug(Case.Subject.getDescribe().length);
Type the following command, check "Open Log" and click "Execute"

4. In the log window, check “Debug Only” and the value that appears to the right of “DEBUG | ” is the length of the field.

In the log window, check "Debug Only" and the value that appears is the length of the field.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Don't Miss Our Pre-Launch Offer on "Mastering Salesforce Flows"

27% Off + FREE Premium Membership

Expires In

:
:
: