Creating a count field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vampirefrog
    Member
    • May 2017
    • 45

    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!
  • tanya
    Senior Member
    • Jun 2014
    • 4308

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

    Comment

    • vampirefrog
      Member
      • May 2017
      • 45

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

      Comment

      Working...