Dynamic Filtering - Component
Dynamic Filtering allows Component Lists to be filtered by values which are contained in another field on a form. This means that the values which are shown in a Component Lookup will vary, depending on the value in another field.
A few examples for such a filter could be
Field on which Filter is applied
|
Dynamic Filtering Rules
|
Responsible Supervisor
|
Only show Persons whose Department matches the current value of the field Department Responsible
|
Meeting Chairperson
|
Only Persons which are listed as Attendees are available for selection as the Chairperson.
|
Parent Action
|
Only show Actions as Parent Actions where these conditions are met:
- Action Number <> Action Number of the current Action
- Action has a Date Raised prior to the current Action
- The Action Sources are identical
|
Assigned To
|
This is an example for using an attribute (field) from a related field:
Only list those persons which have the same Employment Type as the person selected in the Assigned By field.
|
Configuration of Dynamic Filters
|
The implementation of Dynamic Filters will require some manual configuration. Please contact Customer Support if you require further information.
|
To configure a Dynamic Filter, follow these steps.
- Identify which Component needs to be filtered
- In the Form Designer, identify the form field whose content will be used as the "source" for the filter, and write down the Field ElementId.
This ID can be retrieved from the Field Properties of this field. - In the Web Application, Add a new Filter to the Component in Question
- Select the Filter Field, and the correct Operator
- Select Value Type = Value
- Select or enter any random Value (this value will be replaced in a couple of steps)
- Select OK to save your changes.
- In the Web Application, click on Source so you can manually edit the XML condition
- Replace the rhs Condition value which was selected in step 5 above, using the following format:
- When comparing two related records (e.g Persons):
rhs=".FORMFIELD_<Field ElementID>" ,
for example
rhs=".FORMFIELD_ABNylGGXXu8IPwjI4jMM5zHx" - When comparing fields in the related records (e.g. the Employment Status of two Persons):
rhs=".FORMFIELD_<Field ElementID>.<Field_ID>" ,
for example
rhs=".FORMFIELD_ABNylGGXXu8IPwjI4jMM5zG_.bms_9999999_9195"
- You may also have to adjust the type for the condition to work correctly.
Use the type of- attrib for String/Text; Auto Numbers; any Relationships
- date for Date; Time
- i18n for Single Lookup; Multi Lookup; Matrices
- Save your changes
- Next step: Apply this filter to the field that is to be filtered.
- Perform a Publish, and Restart Tomcat
|
- A Dynamic Filter can only be applied to individual Form Fields, and not to a List View
- If a "source field" which is used in a filter is not available on a form, then the filter condition will always return FALSE.
|
|
- If you want to filter a Component Lookup, based on the value of another Component Lookup, you will need to compare the field 'Unique ID'.
See example below.
|
How it works
Like any Filter, Dynamic Filters are designed to facilitate user input. But they cannot be used for validation purposes - you will need to use Server Validation to achieve this.
Dynamic Filter does NOT require the record to be save before the filter becomes active. Any change to the field which determines the content of the dependent Component Lookup will be effective immediately.
However, the filter will only be applied when you actually open the Component Lookup; i.e. if a value is already displayed in the field being filtered and the "source" field is changed, then the content of the filtered field will not change until the Component Lookup List is opened.
For example:
- User selects a Department
- Then the user opens the Component Lookup to select a Supervisor
- The System will only show persons who work in the selected Department.
- The User can select a Person, and click OK
- User selects a different Department
- The content of the Supervisor field will remain unchanged
- The User would be able to save the record
- User opens the Component Lookup to select a Supervisor, having selected a different Department
- The list of available persons will have changed, and only show those who match the currently selected department.
Example 1: Filtering a Component Lookup, 'Source' and 'Target' field are from the same Component
The request is to filter the Component Lookup for 'Actions: Assigned By' to only show the content of the Field 'Incident: Reported by'.
To achieve this, follow these steps:
- Since you are filtering a Person record, you will need to create a Component Filter for the Person Component
- In the Condition Builder, make the following selections:
- Select a Filter Field =
UniqueID - Select an Operator =
EQUAL TO - Select a Value Type =
Value - Enter a Value =
123
- ADD the criteria, and save the filter
- In the Form Designer, retrieve the Field ElementID of the Source Field
- In the Web Application, open the Source Tab, and manually modify the condition. The condition should look similar to this:
<Condition lhs="UniqueId" op="EQ" rhs=".FORMFIELD_ABNylGGXXu8IPwjI4jMM5zG_" type="attrib"/>
- Save changes
- Using the Form Designer, apply the Filter to the correct field on the Actions Form, either as an optional or as a mandatory filter.
- Save changes
- Perform a Publish
Example 2: Filtering a Component Lookup, 'Source' and 'Target' field are from the same Component, and Comparison is against a specific Field
The request is to filter the Component Lookup for Incident: Responsible Supervisor' to only show the persons in the Field Incident: Reported by' which have the same Employment Status.
To achieve this, follow these steps:
- Since you are filtering a Person record, you will need to create a Component Filter for the Person Component
- In the Condition Builder, make the following selections:
- Select a Filter Field =
Person:Employment Type - Select an Operator =
EQUAL TO - Select a Value Type =
Value - Enter a Value =
<any value will do>
- ADD the criteria, and save the filter
- In the Form Designer, retrieve the Field ElementID of the Source Field, i.e. Reported by on the Incident Form.
- In the Filter Builder, open the Source Tab, and manually modify the condition and replace the rhs to refer the Formfield and the related Field. The condition should look similar to this:
<Condition lhs="bms_9999999_9195" op="EQ" rhs=".FORMFIELD_ABNylGGXXu8IPwjI4jMM5zG_.bms_9999999_9195" type="i18n"/> - Save changes
- Using the Form Designer, apply the Filter to the correct field on the Incident Form, either as an optional or as a mandatory filter.
- Save changes
- Perform a Publish
Example 3: Filtering a Component Lookup, 'Source' and 'Target' field are from related Components Here: only show Persons who belong to a Department, which was selected for this record.
The request is to filter the Component Lookup for 'Incident: Responsible Supervisor' to only show persons who work in the Department which was selected in 'Incident: Department Responsible'.
To achieve this, follow these steps:
- Since you are filtering a Person record, you will need to create a Component Filter for the Person Component
- In the Condition Builder, make the following selections:
- Select a Filter Field =
Person/Department - Select an Operator =
EQUAL TO - Select a Value Type =
Value - Enter a Value =
<select any value>
- ADD the criteria, and save the filter
- In the Form Designer, retrieve the Field ElementID of the Source Field
- In the Web Application, open the Source Tab, and manually modify the condition. The condition should look similar to this:
<Condition lhs="bms_FK_9999999_119_ID" op="EQ" type="object">
<Condition lhs="UniqueId" op="EQ" rhs=".FORMFIELD_ABNylGGXXu8IPwjI4jMM5y5u" type="attrib">
<Recurse attrib="ASSOCIATIVE9999999_118"/>
</Condition>
- Save changes
- In the Form Designer, apply the Filter to the correct field on the Incident Form, either as an optional or as a mandatory filter.
- Save changes
- Perform a Publish
Example 4: Filtering a Component Lookup, 'Source' and 'Target' field are from related Components Here: Don't show Persons in a the lookup for "Person Injured" if the same Person already has been listed as Injured for the same Incident
The request is to filter the Component Lookup for 'Injury: Injured or Ill Person' to only show persons who do NOT have been entered as an injured Person for the same Incident which triggered the Injury.
|
The required condition can only be built partially by the Condition Builder. You will have to manually alter the XML to make it work, and therefore the person doing it would need understanding of XML.
You may also find that the saving and the execution of this filter will cause errors in the log files - but these are of no consequence for the end user.
|
To achieve this, start building the condition via the builder, and then complete it manually:
- Since you are filtering a Person record, you will need to create a Component Filter for the Person Component
- In the Condition Builder, make the following selections:
- Select a Filter Field =
Person/Injuries or Illness - Select an Operator =
HAS
- ADD the criteria
- Repeat Step 2, and now select
- Select a Filter Field =
Person/Injuries or Illness/Incident:Incident Number - Select an Operator =
Equal To - Select a Value Type =
Value - Enter a Value =
<select any value>
- ADD the criteria, and save the filter
- The result will be as follows this filter will NOT achieve the required result!
<Condition op="AND">
<Condition entries="true" lhs="ASSOCIATIVE9999999_218" op="EQ" type="object"/>
<Condition lhs="ASSOCIATIVE9999999_218.bms_FK_9999999_220_ID.bms_9999999_1873" op="EQ" rhs="1234" type="text"/>
</Condition>
- Retrieve the Field ElementId for the field Incident:Incident Number: in this example it is
ABNylGGXXu8IPwjI4jMM5zG- - Modify the filter as shown below:
- Remove the AND condition (lines 1 and 4)
- In line 2, remove 'entries = "true" '
- In line 3, ADD 'entries = "true" '
- In line 3, remove the first part of the relationship in the lhs part of the condition, here: 'ASSOCIATIVE9999999_218. '
- In line 3, replace the rhs value with the Field ElementId, here: 'ABNylGGXXu8IPwjI4jMM5zG- '
- In line 3, replace the type with 'attribute '
- And this is how the condition should look like:
<Condition lhs="ASSOCIATIVE9999999_218" op="NE" type="object">
<Condition entries="true" lhs="bms_FK_9999999_220_ID.bms_9999999_1873" op="EQ" rhs=".FORMFIELD_ABNylGGXXu8IPwjI4jMM5zG-" type="attrib"/>
- Save changes.
NOTE: the Condition Builder will not show the condition. - In the Form Designer, apply the Filter to the correct field on the Incident Form, either as an optional or as a mandatory filter.
- Save changes
- Perform a Publish
|