This is step-by-step guide to using Table Reference fields effectively in a workflow's Drag and Drop Form, specifically focusing on dynamic data fetching using SQL clauses based on the logged-in user context.
- Go to left menu > List workflow
- Open & edit the workflow form in the design mode.
- From the Form Controls panel, drag and drop Table Reference Type field
- Click on setting on left corner.
- Go to Data tab you will see a field named Additional SQL Where clause now you can use below keyword as per your requirement.
5.1 DB Table
- Purpose:
Specifies the database table from which records will be fetched. - Example:
#users_master_data - Usage:
This is the base table for your dropdown/lookup. All other configurations work on top of this table.
5.2. Key Column
- Purpose:
The primary key or unique identifier for each record in the DB Table. - Example:
id - Usage:
This value will be stored in the backend when the user selects an item from the dropdown.
5.3. Value Column
- Purpose:
The display column that users will see in the table reference field. - Example:
name, emp_name, dept_name - Usage:
This makes the dropdown human-readable, displaying meaningful text instead of IDs.
5.4 Additional SQL Where Clause
- Purpose:
Allows for dynamic, runtime filtering based on the user
- Few Available Keywords for Reference
a) Get Current User
- Description: Refers to the ID of the currently logged-in user.
- Use Case: To fetch records specific to the logged-in user.
- Example Clause:
id = CURRENT_USER_ID
b) Get the immediate subordinate of the currently logged-in User
- Description: Represents users who report directly to the logged-in user.
- Use Case: To retrieve data related to immediate subordinates.
- Example Clause: Use this with IN
Id IN (IMMEDIATE_REPORTEES_OF_USER)
c) Get a List of All Direct Reportees of the logged-in user
- Description: Represents all direct and indirect subordinates of the logged-in user.
- Use Case: To get data related to the entire reporting hierarchy under the user.
- Example Clause: Use this with IN
id IN (ALL_REPORTEES_OF_USER)
d) Get a List of All Direct Reportees of the logged-in user as HR Spoc
- Description: Refers to employees for whom the logged-in user is assigned as HR Spoc.
- Use Case: Helpful in HR-related workflows.
- Example Clause:
id IN (EMPLOYEES_AS_HRSPOC_OF_USER)
e) Get a list of employees for whom the logged-in user is the HR SPOC, as well as the direct Reporting Manager
- Description: A combination of employees for whom the user is the HR SPOC and the user’s immediate Manager.
- Use Case: To widen the scope of the query to both roles.
- Example Clause:
id IN (EMPLOYEES_AND_IMMEDIATE_REPORTEES_OF_USER)
f) Get a list of employees / all subordinates for whom the logged-in user is the HR SPOC, as well as the direct / skip-level reporting Manager.
- Description: A combined list of employees where the user is the HR SPOC and get all direct/indirect reportees.
- Use Case: Ideal for scenarios requiring access to both HR responsibilities and managerial hierarchy.
- Example Clause:
id IN (EMPLOYEES_AND_ALL_REPORTEES_OF_USER)