Announcement

Collapse
No announcement yet.

How to check for duplicate record using workflow

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

  • How to check for duplicate record using workflow

    Hi,

    We installed this following code under custom folder to check for duplicate record:


    HTML Code:
    <?php
    
    namespace Espo\Custom\Services;
    
    use \Espo\ORM\Entity;
    
    class Billrecord extends \Espo\Core\Templates\Services\BasePlus
    {
        protected function getDuplicateWhereClause(Entity $entity, $data)
        {
            if (!$entity->get('name')) {
                return false;
            }
            return [
                'name' => $entity->get('name')
            ];
        }
    }
    
    ​
    This code works when we create the entity record online but does not seem to work when the record is created using Workflow. This is the workflow definition (the entity name field = Bill/Cover No. field in Workflow. Appreciate any help, please.


    Click image for larger version

Name:	Screenshot_1.png
Views:	357
Size:	37.1 KB
ID:	83810


  • #2
    There's no functionality to call the duplication checking logic neither from a workflow action nor from a formula-script.

    As a workaround you can use a formula-script condition (in your workflow) that checks whether a record with the same name exists. https://docs.espocrm.com/administrat.../#recordexists

    Comment


    • #3
      Hi yuri thank you for the update and help. I have a problem with the suggestion. This is what i am trying to achieve:

      HTML Code:
      ifThen(record\exists('Billrecord', 'name=', billNumber),
      alert('Duplicate Record'));​
      That is, if the record exists, i do not want to create the record as shown in my earlier initial post # 1 above. Also need to notify the user of the error. Please advise. Tq.

      Comment


      • #4
        Unfortunately, there's no ability to invoke any UI modal from the formula (or workflow).

        Comment


        • #5
          Hi yuri , its ok. I adopted your suggestion on using the "record/exists" formula. What i did was to provide a new status "Duplicate #" in the related record that was created. Advised the users on the workaround and got thumbs up for implementation. Hopeful of seeing pop alert functionality at some point in time. Thank you so much for the help.

          Comment

          Working...
          X