Count related records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1673

    #1

    Count related records

    Hello, I have a list of related records, which I count by entity\count related. Countin all record does work.
    These records may have two states, one is sold and one is available. I would like to count the records, which have the bool field sold marked as such. Is that possible? And how? I did not find a solution so far.

    I tested this way

    PHP Code:
    countSold entity\countRelated ('linkRelated''sold='true); 
    but this does not work.
  • lazovic
    Super Moderator
    • Jan 2022
    • 1046

    #2
    Hi shalmaxb,

    The 'sold=', true construction will not work in this case. As a filter, you need to use the List report or a default or custom filter: https://docs.espocrm.com/administration/formula/#filter.

    You can consider the following option:
    Code:
    countSold = record\count('RelatedEntity', 'parentEntityId=', id, 'sold=', true);
    Last edited by lazovic; 05-28-2025, 09:41 AM.

    Comment


    • shalmaxb
      shalmaxb commented
      Editing a comment
      lazovic, thank you. It worked with the last suggestion (record\count).
Working...