This sample script demonstrates how to dynamically filter a grid’s content based on the logged-in user’s status, ensuring that users only see relevant information specific to their role or identity when they open the form.
Applicability
This functionality must be implemented in the pre-form action. This is necessary because the grid content is automatically generated when the form is opened, so the filter must be set up beforehand.
Implementation Steps
- Open Control Properties
- Navigate to the form and select the grid control whose content you want to filter.
- From the Control Properties panel, look for the Control Properties field under the Binding category.
- Click the ellipses (
) inside the field to open the Control Properties window.
- Define the Base Query
- In the Control Properties window, navigate to the Grid tab.
- In the Grid tab, select the Base Info option. This will enable the Query (HQL Only) field.
- Click the Add (
) button next to the Query (HQL Only) field. This will open the Query Editor window.
- In the Query Editor window, define the base query for the grid.
- For example, to fetch action items:
FROM BPMAPP_QMS_ActionItem ai $query
- For example, to fetch action items:
- Modify the Query with Parameters
- Launch the Code Designer by clicking the Edit Code button in the Query Editor window.
- Add the following code to filter the query based on the logged-in user:
parameters.Add("query", "Where Responsible = ' " + bpmAppService.BPMSServices.MercuryService.Currentuser.ID.Trim() + " ' ");