Let's say you have a list of fields on the View page, and you want to hide those that are empty. For this purpose, use the following code in the View page: Before display event for each field you need to hide. This example uses field named EPAHighway.
if (!values["EPAHighway"])
pageObject.hideField("EPAHighway");
Note: There is an option to hide empty fields on the View page automatically. To enable it, go to the Choose pages screen, click the Settings button near the View record checkbox and then select Hide empty fields checkbox.
See also:
•Before display event for all pages except View/Edit