Access atribute of child entity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tomas.klicka
    Junior Member
    • Mar 2023
    • 12

    Access atribute of child entity

    Hi,
    i need to get atribute value from this record and it did not work:

    record\attribute('MontazZakazky', childId, 'montazniPartie')


    This one works but it seems quite messy.
    Don´t you know why the first one does not work?

    record\attribute('MontazZakazky', record\findOne('MontazZakazky', 'createdAt', 'desc', 'parentId=', id), 'montazniPartie')

    Thanks a lot


  • lazovic
    Super Moderator
    • Jan 2022
    • 809

    #2
    Hi tomas.klicka,

    In fact, there is no childId attribute in EspoCRM, it is not created by default after the Parent-to-Children relationship is established. Learn more about attributes here: https://docs.espocrm.com/administrat...ing/#attribute.

    You can simply bring your formula to the following form for convenience and better understanding:​
    Code:
    $childId = record\findOne('MontazZakazky', 'createdAt', 'desc', 'parentId=', id);
    $montazniPartie = record\attribute('MontazZakazky', $childId, 'montazniPartie');

    Comment

    • tomas.klicka
      Junior Member
      • Mar 2023
      • 12

      #3
      Thanks a lot Iazovic, i didn´t know.

      Comment

      Working...