Check Form Size

Update 2017: The size of a form is directly dependent on the underlying database and its features.  In DB2 10.5 the new default is with "extended row size" enabled which means that table definitions can span multiple tablespaces.  For FEB this means that you can create much larger forms.  This script has not yet been updated to account for this change, but you might still find it helpful in understanding approximately how big your form is and what is taking up the most space.  Please remember that this is an approximation and is not exact - I also recognize that there are some bugs in the process that I have not yet been able to work out.


I have encountered a few situations where FEB applications have not been deployable because there were too many UI items (database columns).  The end user will see the following when trying to deploy the application:


If you inspect the logs you will see an error like:

Caused by: com.ibm.db2.jcc.am.SqlException: The row length of the table exceeded a limit of "32677" bytes. (Table space "32677".). SQLCODE=-670, SQLSTATE=54010, DRIVER=3.57.82

So I set out trying to figure out how big each of our widgets are so that we could calculate how close a form is to the edge.  All of the numbers provided here are approximate.

When you add an item to the form a column is created and the size of that column is dependent on the type of item.  The maximum size is 32677 bytes.
 

WidgetBytesNotes
Multi-line Field164Defined as CLOB(1000000)
Single-line Field4 bytes per charDefined as VARCHAR(4-1024) where length is 1-256
Checklist140Defined as CLOB(102400)
Date4Defined as DATE
Dropdown1-800Defined as VARCHAR(4-800). Dropdown value can be 1- 200 characters
Survey50-800Defined as VARCHAR(50-800). Survey answer can be 1-200 characters
Number (Decimal), Currency12Defined as DECIMAL()
Number (Integer)8Defined as BIGINT
Time4Defined as TIME
Email100Defined as VARCHAR(100)
Radiolist208-800Defined as VARCHAR(52-200) where length is 1-200
Check4Defined as SMALLINT
Weblink112Defined as CLOB(2048)
Password200Defined as VARCHAR(200)
Timestamp12Defined as TIMESTAMP

Practical Usage:

With these values we could calculate approximately how big a form is and how much space is left.  I created some JavaScript that can do the calculation for you.

1. Create a button in the form you want to test.

2. Add the following js file to your application: tableSpaceSize.js

3. Add the following JS to the onClick of the button:

app.getSharedData().getTableSpaceSize(form.getId());

4. Preview the form and click the button to see how much space is being used!

Examples:

- You could have a form with 31 SingleLine fields where they were set to the maximum field length of 256 characters.
- You could have a form with 158 SingleLine fields where they were set to the maximum field length of 50 characters.
- You could have a form with 190 MultiLine fields.
- You could have a form with 625 Yes/No Survey questions
- You could have a form with 40 Survey Questions where the question value is at its 200 character max


How to reduce the size of your form

Now that you have found out that your form is too big what can you do?

1. The default character length for many of the items is 50, if you have fields where you know the input will be less then the default then make that number smaller.

2. If you are using SingleLine fields where a user can enter lots of text, then use a MultiLine instead.  The size contribution of a MultiLine field is much less than a single-line field.

3. Determine if it really makes sense for all of these fields to be in ONE form.  Perhaps you should break up the data retrieval process into multiple forms.


Version History

- Sept 8, 2014: If a field is hidden by a rule then the code doesn't calculate properly.  Added a check to insure the single line field is visible before attempting to calculate its character size.  Changed the single line field check to be more precise then the previous version.
 

Related pages