Announcement

Collapse
No announcement yet.

Additional data in Filter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

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

  • #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',
                
    nameHashnameHash
              
    },
            };

          }

          return 
    Promise.resolve({
            
    advancedadvanced,
          });
        }

      }
    });
    ​ 
    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...
    X