Sometimes we came across the scenario of hiding the field on onload of page (View mode) as well as OnChange of page (Edit mode). For this you have to write script. In this blog I would like to represent easy and simple way to do this.
Consider a scenario where oppo_sectionalready is a checkbox field of Opportunity entity. Now, you want to hide a field oppo_sectionalready if checkbox is not checked and show the field when the checkbox is unchecked.
1. Firstly, you need to check whether you are getting the object of the field.
In Edit mode using document.EntryForm.oppo_sectionalready
In View mode using document.getElementById(“_HIDDENoppo_sectionalready”)
2. Once the you are getting the object in both modes, then you just need to check the value of a field and accordingly, hide and show the Caption part as well as the Data part of a field.
The script for the same is as follows.