Announcement

Collapse
No announcement yet.

Creating a count field

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

  • Creating a count field

    Hello. I'd like to create a field that is simply the count of related entities in a related table. I have been able to do this by adding "select": "(SELECT COUNT(*) FROM related_entity WHERE related_entity.fk_id = this_entity.id)", but I cannot sort by this value. Is there a way to have a count field and also be able to sort by it? Thanks!

  • #2
    Hello
    Try to set orderBy as well
    an example in application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.php amountWeightedConverted field amountWeightedConverted

    Comment


    • #3
      Thank you Tanya, I will have a look.

      Comment

      Working...
      X