Step 1: First of all, get the schema names of the field “Account Name” and “Consultations” Subgrid.
This can also be done by opening the form editor and then double clicking on the specific field and Subgrids as shown in the figures below.
var formContext = executionContext.getFormContext();// get the form Context
var accountname = formContext.getAttribute(“parentcustomerid”).getValue();// get the value of accountname
if(accountname !== null)
Step 3: Register “ShowhideSubgrid” function on form load.
As per the Fig.4, go to form properties in form editor to add new libraries.
As noted in the Fig.5, Click ‘Add’ button in form libraries for adding new libraries.
Now, click on the ‘Add’ button in event handlers to add the function ‘ShowhideSubgrid’ on loading of form. Also, select the ‘control’ as Form and ‘Event’ as OnLoad as shown in Fig.8.
Step 4: Register “ShowhideSubgrid” function on Change of the Field “Account Name”.
As explained in the above figures, in order to register the function ‘ShowhideSubgrid’ on change of the field “Account Name”, double click on the field to reach to the events tab.
In the events tab, you can click on the ‘Add’ button by selecting the respective field “Account Name” in ‘Control’ and setting the ‘Event’ to ‘OnChange’.
Similarly, in the Handler Properties, choose the respective JScript library and enter the ‘ShowhideSubgrid’ function. Also, check the ‘Pass execution context as first parameter’ box as shown in Fig.12.
Now, before leaving the Form Editor, save and publish the customizations performed as shown in Fig.13.
- When the Field “Account Name” is empty, then “Consultations” Subgrid is visible.
- When the Field “Account Name” is not empty, then “Consultations” Subgrid is not visible.
Hope it helps !