Using "Foreign" Field in EspoCRM Formula

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alohatech
    Junior Member
    • May 2024
    • 17

    Using "Foreign" Field in EspoCRM Formula

    Hello,

    I am trying to use a foreign field (a read-only field from a related record) within a formula in EspoCRM, but it returns nothing. How can I properly access and use the value of a foreign field in a formula?

    Thank you for your assistance!
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    Hey

    share code here, it should work. what kind of relationship between the entities etc. below an example how to access accountType foreign field on contact (which the type field in account). This is tested in sandbox


    PHP Code:
    $id = record\findRelatedOne('Account', id, 'contacts', 'createdAt', 'desc');
    
    $type = record\attribute('Contact', $id, 'accountType');
    
    output\print($type);
    Rabii
    Web Dev

    Comment

    Working...