FlowChart check duplicates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jd13579
    Junior Member
    • Jun 2021
    • 7

    FlowChart check duplicates

    Hello,

    I am trying to get update a specific lead, and check if there is already duplicate who has the same phone or email, I am still a little bit new to the flowchart formulas.

    How can I check for duplicates by phone or number in the BPM flowchart?

    Many Thanks!
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    check this out https://docs.espocrm.com/development/duplicate-check/
    Rabii
    Web Dev

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #3
      You can utilize formula record\exists function. Assign the result of the function to a variable. Then check the variable value in a gateway element. If the variable is not empty, it means there's a duplicate.

      In a Script Task:

      Code:
      $phoneNumber = entity\attribute('phoneNumber');
      $emailAddress = entity\attribute('emailAddress');
      
      $hasDuplicate =
          ifThenElse(
              $phoneNumber,
              record\exists('Lead', 'phoneNumber=', $phoneNumber),
              false
          ) ||
          ifThenElse(
              $emailAddress,
              record\exists('Lead', 'emailAddress=', $emailAddress),
              false
          );
      Last edited by yuri; 12-25-2021, 10:22 AM.
      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

      • alexisc
        Senior Member
        • Aug 2019
        • 135

        #4
        I try this code on gateway element, it doesn't work, what am I doing wrong?

        Code:
        $phoneNumber = entity\attribute('phoneNumber');
        
        $hasDuplicate =
        ifThenElse(
        $phoneNumber,
        record\exists('Lead', 'phoneNumber=', $phoneNumber),
        false
        );

        Comment


        • rabii
          rabii commented
          Editing a comment
          remove the semi-colon and try again.
      • alexisc
        Senior Member
        • Aug 2019
        • 135

        #5
        does not work

        I want to check using BPM for matches by phone number when creating and launch an additional action based on the result of the check, if anyone has a solution, please share
        Last edited by alexisc; 04-22-2022, 11:03 AM.

        Comment

        • yuri
          Member
          • Mar 2014
          • 8440

          #6
          In condition there should be only one expression. You could use the formula before the gateway in the script task, and then check only variable in the gateway (as variable is an expression too).

          Or try this in gateway:

          Code:
          ifThenElse(
              entity\attribute('phoneNumber'),
              record\exists(
                  'Lead',
                  'phoneNumber=', entity\attribute('phoneNumber'),
                  'id!=', entity\attribute('id')
              ),
              false
          );
          This is a single expression.
          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

          • alexisc
            Senior Member
            • Aug 2019
            • 135

            #7
            this formula works, thank you very much!!!

            Comment

            Working...