Duplicate checking fields - V8.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1602

    #16
    I need a condition, that checks a duplicate number in the given exhibition. The number should be unique for an unique exhibition, but the number could appear in another exhibition again of course.

    In other words, the duplicate check should only happen for the current exhibition, where I number the existing and new items (artwork) exhibited in that one exhibition. I don`t care if a number is already existing in another exhibition.
    Last edited by shalmaxb; 10-23-2023, 10:28 AM.

    Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #17
      what do you mean ? i am honestly confused when you said you don't care if the number exist in another exhibition ? so what is the point f using duplicate check on the number then. if i understand this is to do only with the exhibition entity and has nothing to do with the items.

      The number should be unique for an unique exhibition, but the number could appear in another exhibition again of course.
      Rabii
      Web Dev

      Comment

      • shalmaxb
        Senior Member
        • Mar 2015
        • 1602

        #18
        The exhibition items are in a from exhibition separated entity linked by relationship. So I have the items for all exhibitions in the entity WerkeAusstellungen. There might be items 1 to 10 for exhibition X and 1 to 15 for exhibition Y and so on.
        So I do not need to check, if in exhibtion X there is already a number, which I need for exhibition Y, I only have to check in exhibition items Y.
        The duplicate check has to happen in the linked entity with all items, limited to the items, that belong to one certain exhibition.

        I know it is not easy to understand, nor to explain.....
        But in fact it is quite simple.

        Click image for larger version

Name:	wvz_exhibition_item_numbering.jpg
Views:	216
Size:	49.5 KB
ID:	98934

        Comment


        • shalmaxb
          shalmaxb commented
          Editing a comment
          this check works as desired on update. That means, when I change a number in the list to a number already existing, it throws the warning and displays the existing work with that number. Would it not work on recordNew?

        • rabii
          rabii commented
          Editing a comment
          if it works on update it must work on create by default. can you check if you have a API before formula script that triggers the message.

        • shalmaxb
          shalmaxb commented
          Editing a comment
          No API before formula script. The duplicate check takes place in the (linked) entity only and itself, I check the conditions in this one entity.
      • shalmaxb
        Senior Member
        • Mar 2015
        • 1602

        #19
        I think I found the reason, why it is not working on create record. The duplicate check depends on the common field "vernissage", means, that the record is checked against that field, which is present in existing exhibition items, but not in a not yet saved item, as it will be fetched through the relationship only on saving. That means, that the duplicate check for a related field cannot work, as the value isn`t present yet.

        I added now for that entity an API before save script:

        Code:
        if (!recordService\skipDuplicateCheck() || entity\isAttributeChanged('ausstellungsnummer')) {
        $id = record\findOne('WerkeAusstellungen', 'vernissage', 'desc', 'ausstellungsnummer=', ausstellungsnummer);
        
        if ($id) {
        recordService\throwDuplicateConflict($id);
        }
        }


        and now it works (though I do not really understand yet, how that works).

        To explain, what this script does:

        For a new record it looks for the current exhibition/vernissage ordered by the most recent vernissage date (because that is an exhibition in preparation and so the numbering may be changed until opening). If the number is present already, it throws the duplicate warning.

        If an existing record gets inserted a new number for some reason, the duplicate check will be against the already existing numbers and if present already throws the duplicate warning as well.
        Last edited by shalmaxb; 10-23-2023, 06:26 PM.

        Comment

        • PrototypeX
          Junior Member
          • Nov 2018
          • 6

          #20
          This formula

          if (recordService\skipDuplicateCheck()) {
          recordService\throwForbidden("No duplicate check bypass allowed.");
          }​


          works as intended if f you are creating manually but if you are converting a lead to account and is already there its seams to me that is ignoring it.
          Any suggestions?
          Thank you​

          Comment

          • Davidjuan
            Junior Member
            • Jun 2024
            • 3

            #21

            It sounds like you've set up the duplicate check fields, but you’re still able to create duplicate entries. Here are a few steps you can follow to ensure the duplicate check works correctly:

            1. Verify Duplicate Check Configuration:
            - Make sure the fields you've selected for duplicate checking are correctly configured.
            - Ensure the duplicate check feature is enabled in the settings.

            2. Set the Name Field as Unique:
            - Since you're using the default name field as a serial number, it should be unique. You might need to enforce this at the database level to prevent duplicates.

            3. Backend Configuration:
            - Check if there's a unique constraint on the `name` field in your database schema. If not, you may need to add it.
            - For example, in SQL, you can set a unique constraint like this:
            ```sql
            ALTER TABLE your_table_name
            ADD CONSTRAINT unique_name UNIQUE (name);
            ```

            4. Custom Validation:
            - Implement custom validation logic in your application to check for duplicates before saving new entries. This can be done in the backend code where entries are processed.

            5. Clear Cache and Restart:
            - Sometimes, changes require a cache clear or a restart of your application for them to take effect.

            If you’ve already done the above and the issue persists, please provide more details about your setup or any error messages you might be seeing. This will help in diagnosing the problem more precisely.

            I hope this helps! Let me know if you need further assistance.​

            Comment

            • Ashif Malayil
              Senior Member
              • Dec 2023
              • 171

              #22
              Originally posted by rabii
              But if you want to force the user to not create the entity when a duplicate is found, you need to add the code mentioned by Yuri above

              PHP Code:
              if (recordService\skipDuplicateCheck()) {
              recordService\throwForbidden("No duplicate check bypass allowed.");
              }
              Meaning when system find a duplicate if the user clicks on create they will get the error (No duplicate bypass allowed) and this will stop them from creating duplicated record.
              There is one issue, User 1 has created 1 Lead after that that User 2 also created same Lead, in this time it's not showing any duplicate alert or the access denied error of the formula we added. It's straightly getting created. I think this because of the ACL of users. I need to restrict this. How can i resolve this?​
              Last edited by Ashif Malayil; 06-13-2024, 07:52 AM.

              Comment

              Working...