Additional data in Filter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kacper
    Junior Member
    • Oct 2023
    • 29

    Additional data in Filter

    Hello!

    I have m:n relation. In the relation selection I want to add a filter that will show me only those entities that are not already connected, how do I do it?
    I wanted to add an Espo\Core\Select\Primary\Filter, however, the parent ID is not injected into it, and as a result I am not able to find the relation in the pivot table​.
    Is it at all possible to inject into SelectBuilder from Filter something more than just the entity by which we filter?
  • a.slyzhko
    Member
    • Oct 2023
    • 96

    #2
    You need to selectHandler for frontend part. Here is example of my implementation of such functionality
    PHP Code:
    define([], () => {
      return class {
        getFilters(model) {
          let advanced = {};
    
          if (model.id) {
            let nameHash = {};
            nameHash[model.id] = model.get('name');
    
            advanced.linkA = {
              type: 'notLinkedWith',
              field: 'linkA',
              value: [model.id],
              data: {
                type: 'noneOf',
                nameHash: nameHash
              },
            };
    
          }
    
          return Promise.resolve({
            advanced: advanced,
          });
        }
    
      }
    });
    Then define metadata ->clientDefs -> your entity type -> relationshipPanels -> linkA -> selectHandler -> this js script

    And do the same for entity A but change linkA with linkB
    Last edited by a.slyzhko; 07-09-2024, 01:33 PM.

    Comment

    Working...