Can record\exists formula Value be from another Entity?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JosNas
    Member
    • Sep 2021
    • 97

    Can record\exists formula Value be from another Entity?

    I'm checking if an Account record exists based on the value of the accountName field in a Lead record. If it exists, I don't want to create a record in 'Accounts', else create the record.

    Can I do it like this using the workflow formula (target Entity is 'Lead '):

    Code:
    ifThen(
    !record\exists('Account', 'name=', accountName),
    record\create('Account', 'name', accountName))
  • eymen-elkum
    Active Community Member
    • Nov 2014
    • 472

    #2
    You can use record\findOne:

    Code:
    $accId = record\findOne('Account', 'createdAt', 'desc', 'name=', accountName);
    ifThen(
        $accId == null,
        record\create('Account', 'name', accountName));
    );
    CEO of Eblasoft
    EspoCRM Expert since 2014
    Full Stack Web Developer since 2008
    Creator of Numerous Successful Extensions & Projects​

    Comment


    • JosNas
      JosNas commented
      Editing a comment
      thank you this worked like a charm!
  • eduardofendrich
    Member
    • Jul 2021
    • 49

    #3
    Should this work in the following situation?

    User has a team assigned. User is creating a contact. I would like to set contact's team to the same user's team.

    How can I get current user settings in formula? Does '$this' works?


    Thanks

    Comment


    • eymen-elkum
      eymen-elkum commented
      Editing a comment
      Yes you can use: env\userAttribute('teamsIds')
Working...