Grabbing data from a related entity to override current info with formula script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nramsay
    Junior Member
    • Jul 2025
    • 13

    #1

    Grabbing data from a related entity to override current info with formula script

    I've an entity called 'Web Deliveries' here that has shipping address fields so we know where to send things. If the delivery is going to a contact we current have in the system (repeat customer), I can attach that contact to the Web Deliveries entity. What I'd like is to be able to overwrite the shipping address information from the attached contact if I attach one.

    I assume I want to grab fields from record. But how do I code it to only grab the fields if I've attached the contact entity?
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9287

    #2
    Assuming the link name is 'contact', the address field name is 'shippingAddress'.

    Code:
    if (contact && contact.shippingAddressStreet) {
        shippingAddressStreet = contact.addressStreet;
        shippingAddressCity = contact.addressCity;
        shippingAddressPostalCode = contact.addressPostalCode;
        shippingAddressState = contact.addressState;
        shippingAddressCountry = contact.addressCountry;
    }
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...