Announcement

Collapse
No announcement yet.

Can record\exists formula Value be from another Entity?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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))

  • #2
    You can use record\findOne:

    Code:
    $accId = record\findOne('Account', 'createdAt', 'desc', 'name=', accountName);
    ifThen(
        $accId == null,
        record\create('Account', 'name', accountName));
    );
    CEO & Founder of Eblasoft.
    Professional EspoCRM development & extensions.

    Comment


    • JosNas
      JosNas commented
      Editing a comment
      thank you this worked like a charm!

  • #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...
X