Where can Groovy script be used to restrict the display and selection of portlets?
Groovy script can be used to restrict the display and selection of portlets in the properties dialog of the following:
"Portlet container" element
View page / "Portlet" tab
Application properties / "Portlet" tab
Click here for more information.
Display and selection without a filter
In a simple application, which was created with the "Basic application" template, values are entered and displayed on the application homepage.
This page has been configured to be used as a portlet. Additionally, the setting "Portlet is available in other applications" has been set, meaning the portlet can be added to the portal homepage as well.
As a result, the "Values" portlet can now be selected under "Portlets from applications" and moved to a container of your choice via drag & drop. Click here for general information about this subject.
All users can now see the portlet.
Restrict the selection and/or display of the portlet in the browser with Groovy script
The following script means that the portlet is only displayed if the table contains data records; the "Restrict display of the portlet on the web by Groovy script" setting must be activated. The script can also be used if the "Restrict selection of the portlet on the web by Groovy script" is activated. In this case, the portlet will no longer be listed under "Portlets and applications" on the portlet settings page and cannot be added to the portal page if the table does not contain any records.
g_dataCollection.getDataRange("768A3C783F2BC9FD7EF20B1979FD3B27498779E2").getNumberOfRecords() > 0
Replace the GUID in this script with the <tablerecords> GUIDs of your view page.
Select the "Values" page and select "Show elements" from the Show elements menu to show the elements in the Application structure. Go through the structure until you find the table and the "tablerecords" entry beneath it. Open the properties of the entry by double-clicking on it. You will find the GUID on the "Expert" tab.