Announcement

Collapse
No announcement yet.

getSelectFilters: "isNotEmpty" as type filter is not working

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

  • getSelectFilters: "isNotEmpty" as type filter is not working

    Hello,
    we want to pre-filter our relation field search by another entity.

    If we use the type "equals" everything works fine, but if we add filter type "isNotEmpty" the search is executed but the result is only filtered by "equals" filter but not by "isNotEmpty".

    When we execute the search manually, the result is correctly filtered by "equals" and "isNotEmpty" types. So it seems that the "isNotEmpty" type filter is ignored in our case.


    Tested with versions:
    5.4.5. and 5.9.3


    Questions:
    • Is the type "isNotEmpty" correct to filter for not empty results?
    • What else must be included (value, attribute, etc.) in the JSON section so that the "isNotEmpty" type is not ignored and directly executed?

    Screenshot:
    Click image for larger version  Name:	isNotEmpty Filter.png Views:	0 Size:	26.0 KB ID:	61470



    Code:
    Espo.define('custom:views/vertrag/fields/kostenstelle', 'views/fields/link', function (Dep) {
    
    return Dep.extend({
    
    getSelectFilters: function () {
    var mandant = this.model.attributes.mandantId;
    var mandantName = this.model.get('mandantName');
    
    if (mandant) {
    return {
    'mandant': {
    type: 'equals', // this works fine
    field: 'mandantId',
    value: mandant,
    valueName: mandantName
    },
    'objekte': {
    type: 'isNotEmpty', // does not work
    attribute: 'objekte'
    }
    };
    }
    }
    });
    });

    Best regards,
    Thomas Kutschker






    Attached Files

  • #2
    Hello,

    try to use "objekteId" instead of "objekte":


    HTML Code:
    'objekte': {
        type: 'isNotEmpty',
        attribute: 'objekteId'
    }
    Last edited by eymen-elkum; 08-12-2020, 09:18 AM.
    CEO & Founder of Eblasoft.
    Professional EspoCRM development & extensions.

    Comment


    • #3
      Hello,
      seems not to work, tried it with all related fields .. also without attribute key on another field:

      Code:
      'mandantsearch': {
         type: 'isNotEmpty'
      }
      The problem is that the filter is shown, but the results are not filtered by this filter (as on screenshot above).


      Have you used the "isNotEmpty" filter yourself on a project?

      Best regards,
      Thomas

      Comment


      • #4
        Hi,

        The problem is that the filter is shown, but the results are not filtered by this filter (as on screenshot above).

        Have you used the "isNotEmpty" filter yourself on a project?
        I checked the full code and couldn't find any reference to the 'isNotEmpty' condition used for link field filtering. Not sure if its even possible.

        The only filtering conditions that I see for link fields are: "in" (as contained in an array) and "equals"

        You can use your code editor or IDE and do a search for getSelectFilters: function () and see how it's been used.

        Hope this helps
        Last edited by telecastg; 08-12-2020, 04:42 PM.

        Comment


        • #5
          Hi Thomas,

          There is no example in all the code of espocrm, so I had to try it by myself.

          Please follow the code in the picture bellow, must works:


          Click image for larger version  Name:	image_4734.png Views:	6 Size:	101.9 KB ID:	61540

          Code:
             getSelectFilters: function () {
                var mandant = this.model.attributes.mandantId;
                var mandantName = this.model.get('mandantName');
          
                if (mandant) {
                   return {
                      'mandant': {
                         type: 'equals',
                         field: 'mandantId',
                         value: mandant,
                         valueName: mandantName
                      },
                      'objekte': { // here no Id required
                         type: 'isNotNull',
                         attribute: 'objekteId', // dont forget the Id
                         data: {
                            type: 'isNotEmpty'
                         }
                      }
                   };
                }
             },
          Attached Files
          Last edited by eymen-elkum; 08-13-2020, 07:27 AM.
          CEO & Founder of Eblasoft.
          Professional EspoCRM development & extensions.

          Comment


        • #6
          Hello,
          thank you eymen-elkum for the detailed answer, your solution works perfect

          Best regards,
          Thomas

          Comment


          • eymen-elkum
            eymen-elkum commented
            Editing a comment
            You are welcome

        • #7
          Wouldn't this be considered a bug and a pull request should be accepted? Considering the Filter is not working.

          Comment


          • telecastg
            telecastg commented
            Editing a comment
            I don't think that this is a bug, it's learning how to properly format a filtering condition.

            It was difficult because the syntax is not documented and there is no example code in the code base to follow, but the functionality is as intended and now thanks to eymen-elkum we know how to implement it :-).
        Working...
        X