Retrieving Email Addresses with Formula

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • serqet
    Senior Member
    • Feb 2019
    • 111

    Retrieving Email Addresses with Formula

    Hello,

    I have an entity named XXX. I created a Many-to-Many relationship with the User entity to this entity.

    When opening a new record, I added more than one user (in this example 3) and I want to get the email addresses of these users.

    I am trying the following code in the protected formula field and the user ids are coming but I want to get the email addresses because I will send emails to these people via formula. How can I do it masters?
    Thanks.

    $userId = usersssIds;
    $id = record\findMany('User', 10, 'createdAt', 'desc', 'id=', $userId);
    output\printLine($id);

    Output= ["64f6fde53a78363bf","5d0750b4736cdc843","5c324 7155 7bb104ae"]​
  • yuri
    Member
    • Mar 2014
    • 8562

    #2
    Code:
    // User IDs in $ids variable.
    
    $emailAddresses = list();
    
    $i = 0;
    
    while ($i < array\length($ids)) {
        $userId = array\at($ids, $i);
        
        $emailAddress = record\attribute('User', $userId, 'emailAddress');
        
        if ($emailAddress) {
            $emailAddresses = array\push($emailAddresses, $emailAddress);
        }
        
        $i = $i + 1;
    }​
    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...