Announcement

Collapse
No announcement yet.

how to filter template view

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

  • how to filter template view

    Hi,

    How can I filter the pdf template view for something else than only the entity-type... like for example: name or title.

    this.createView("pdfTemplate", "views/modals/select-template", { entityType: this.entityType }, e=> { ... }

  • #2
    Hi there,

    In this case you can give another option parameter named "filters" when creating the view.


    This shoud look like this :
    Code:
    this.createView("pdfTemplate", "views/modals/select-template", {
       entityType: this.entityType,
       filters: {
          'fieldName': {
             type: 'equals',
             value: 'matchingValue'
          }
       }
    }, e=> { ... }​
    Regards,
    Firyo.
    Last edited by Firyo; 12-28-2023, 08:51 AM. Reason: indent

    Comment


    • #3

      Hi,

      thanks .. Happy new year !!! ... cool beans, .. but .. didn't work ...

      Code:
      this.createView("pdfTemplate", "views/modals/select-template", {
           entityType: this.entityType,
           filters: {
              'title': {
                  type: 'equals',
                  value: 'Christmas' }
           }
      }, e=> {
      as you can see what I have, it is a template for "Christmas" ... that I wanna be able to use .. that's it. .. but does not work.

      (the URL in the browser network tab) .. always looks like:

      /api/v1/Template?select=name,name&maxSize=10&offset=0&orde rBy=name&order=asc&where[0][type]=equals&where[0][attribute]=entityType&where[0][value]=Letters

      the "title" on the where .. will never appears. ( version 8.0.3 )
      Last edited by jugama; 12-29-2023, 11:52 PM.

      Comment


      • #4
        Hi,

        AFAK there is no title in espocrm unless this is a new field you created, i would suggest to get the template using the name attribute like below:

        PHP Code:
        this.createView("pdfTemplate""views/modals/select-template", {
             
        entityTypethis.entityType,
             
        filters: {
                
        'name': {
                    
        type'equals',
                    
        value'Christmas' }
             }
        }, 
        e=> {​​ 
        Rabii
        Web Dev

        Comment


        • jugama
          jugama commented
          Editing a comment
          Hi,

          That does NOT works at all. .. I tried already 2 times before reply, and 2 times now after you responded me.

          thanks anyway for you response.

      • #5
        I have just checked again and you are right, the raison why it doesn't work is because by default the pdf template entity has no other fields to filter with (only entityType) hence why if you try to filter by a field that doesn't exist on the filter list it won't work. you need to enable customisation on the template and then add required fields on the filter list and it should work fine. Maybe enable default filters if required.
        Rabii
        Web Dev

        Comment

        Working...
        X