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

note_awesome

The implementation of Dynamic Filters will require some manual configuration. Please contact the SAI360 Help Desk if you require further information.

To configure a Dynamic Filter, follow these steps.

  1. Identify which Component needs to be filtered
  2. 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.
  3. In the Web Application, Add a new Filter to the Component in Question
  4. Select the Filter Field, and the correct Operator
  5. Select Value Type = Value
  6. Select or enter any random Value (this value will be replaced in a couple of steps)
  7. Select OK to save your changes.
  8. In the Web Application, click on Source so you can manually edit the XML condition
  9. Replace the rhs Condition value which was selected in step 5 above, using the following format:
    1. When comparing two related records (e.g Persons):
      rhs=".FORMFIELD_<Field ElementID>",

      for example
      rhs=".FORMFIELD_ABNylGGXXu8IPwjI4jMM5zHx"
    2. 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"
  10. 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
  11. Save your changes
  12. Next step: Apply this filter to the field that is to be filtered.
  13. Perform a Publish, and Restart Tomcat

note_awesome

  • 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.

note_awesome

  • 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.

note_awesome

  • If the source for the Dynamic Filter is a Multi-Component Lookup, the you will need to use the IN instead of the EQ operator.

    For example:
    <Condition lhs="UniqueId" op="IN" rhs=".FORMFIELD_AFBWtAByMTM0NDIzNzI0OTY4" type="attrib"/>

    where the .FORMFIELD is a multi-component lookup

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 dependant 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:

  1. Since you are filtering a Person record, you will need to create a Component Filter for the Person Component
  2. 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
  3. ADD the criteria, and save the filter
  4. In the Form Designer, retrieve the Field ElementID of the Source Field
  5. 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"/>

  6. Save changes
  7. Using the Form Designer, apply the Filter to the correct field on the Actions Form, either as an optional or as a mandatory filter.
  8. Save changes
  9. 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:

  1. Since you are filtering a Person record, you will need to create a Component Filter for the Person Component
  2. 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>
  3. ADD the criteria, and save the filter
  4. In the Form Designer, retrieve the Field ElementID of the Source Field, i.e. Reported by on the Incident Form.
  5. 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"/>
  6. Save changes
  7. Using the Form Designer, apply the Filter to the correct field on the Incident Form, either as an optional or as a mandatory filter.
  8. Save changes
  9. 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:

  1. Since you are filtering a Person record, you will need to create a Component Filter for the Person Component
  2. 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>
  3. ADD the criteria, and save the filter
  4. In the Form Designer, retrieve the Field ElementID of the Source Field
  5. 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>

  6. Save changes
  7. In the Form Designer, apply the Filter to the correct field on the Incident Form, either as an optional or as a mandatory filter.
  8. Save changes
  9. 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.

Warning

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:

  1. Since you are filtering a Person record, you will need to create a Component Filter for the Person Component
  2. In the Condition Builder, make the following selections:
    • Select a Filter Field = Person/Injuries or Illness
    • Select an Operator = HAS
  3. ADD the criteria
  4. 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>
  5. ADD the criteria, and save the filter
  6. The result will be as follows Menu path separator 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>

  7. Retrieve the Field ElementId for the field Incident:Incident Number: in this example it is ABNylGGXXu8IPwjI4jMM5zG-
  8. 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'

  9. 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"/>

  10. Save changes.
    NOTE: the Condition Builder will not show the condition.
  11. In the Form Designer, apply the Filter to the correct field on the Incident Form, either as an optional or as a mandatory filter.
  12. Save changes
  13. Perform a Publish

See Also

Filters

Filters: Overview

Add a Filter to a Component

Add a Filter to a Lookup List

Dynamic Filtering - Lookup Lists