Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Controlling the field list for field comparisons in FilterBuilder

    When defining field comparisons in FilterBuilder, we need to control the list of fields displayed in the value section.

    for example: Field A equals Field B

    We choose Field A from a list we control but we want to control the list from which we choose Field B.

    We are using version 13.0-p20230315 but we are planning to upgrade to 14.x soon.

    #2
    Presumably you are talking about using a filterBuilder to create a greaterThanField or similar field-to-field comparison Criterion. If so, you can use an override of getValueFieldProperties() to supply the list of fields you want via returning a valueMap.

    Something like this:

    Code:
    isc.FilterBuilder.create({
          dataSource: myDS,
    
          getValueFieldProperties: function(type, fieldName, operatorId, itemType) {
              // itemType == "name" indicates the field picker for field-to-field comparisons
              if (itemType == "name") {
                  return {
                      valueMap: {
                          "allowedField1": "Allowed Field 1",
                          "allowedField2": "Allowed Field 2"
                      }
                  };
              }
              return this.Super("getValueFieldProperties", arguments);
          }
      });

    Comment


      #3
      We were suspecting that getValueFieldProperties() would be the way.

      However, we are using the Java API and trying to restrict the "equalsField" operator to fields of TEXT type only.

      Can you please provide a Java example ?
      Would the following be a good starting point ?
      If yes, can you help us fill the gaps ?

      Code:
      @Override
      public FormItem getValueFieldProperties(
                                             final FieldType type,
                                             final String fieldName,
                                             final OperatorId operatorId,
                                             final ValueItemType itemType,
                                             final String fieldType
      ) {
      
          if (type.equals(FieldType.TEXT) && itemType.equals(ValueItemType.NAME)) {
              // custom list
              // ...
          }
      
          // default behaviour
          return super.getValueFieldProperties(type, fieldName, operatorId, itemType, fieldType);
      }
      Last edited by eliasbalasis; 25 Jan 2026, 11:49.

      Comment


        #4
        We don't provide code samples on demand, except for customers with hourly support. But you're close and AI could finish it for you.

        Comment


          #5
          I am afraid we cannot consider this helpful.

          However, we tried to decode your JavaScript code to the best of our understanding, and tried the following:

          Code:
          @Override
              public FormItem getValueFieldProperties(final FieldType type,
                                                      final String fieldName,
                                                      final OperatorId operatorId,
                                                      final ValueItemType itemType,
                                                      final String fieldType) {
          
                  if (itemType.equals(ValueItemType.NAME)) {
          
                      // for field comparisons
                      // choose only fields of same type
                      final Map<String, String> valueMap = new LinkedHashMap<>();
                      ...
                              valueMap.put(fieldAttributeName, fieldAttributeTitle);
                      ...
          
                      final SelectItem formItem = new SelectItem();
                      formItem.setValueMap(valueMap);
                      return formItem;
                  }
          
                  return super.getValueFieldProperties(type, fieldName, operatorId, itemType, fieldType);
              }
          Unfortunately, it did not work.

          Are we missing something ?
          Is your code missing something ?
          Last edited by eliasbalasis; 26 Jan 2026, 06:38.

          Comment


            #6
            We have discovered the missing part.

            Code:
            @Override
                public FormItem getValueFieldProperties(final FieldType type,
                                                        final String fieldName,
                                                        final OperatorId operatorId,
                                                        final ValueItemType itemType,
                                                        final String fieldType) {
            
                    if (itemType.equals(ValueItemType.NAME)) {
            
                        // for field comparisons
                        // choose only fields of same type
                        final Map<String, String> valueMap = new LinkedHashMap<>();
                        ...
                                valueMap.put(fieldAttributeName, fieldAttributeTitle);
                        ...
            
                        final SelectItem formItem = new SelectItem();
                        formItem.setOptionDataSource((DataSource) null);
                        formItem.setValueMap(valueMap);
                        return formItem;
                    }
            
                    return super.getValueFieldProperties(type, fieldName, operatorId, itemType, fieldType);
                }
            The "formItem.setOptionDataSource((DataSource) null);" was required.

            We have figured this out and the drop-down now gets populated with only the matching fields.

            Comment

            Working...
            X