Announcement

Collapse
No announcement yet.

Duplicate checking fields - V8.0

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

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


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

      Comment


      • #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:	117
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.

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

        Working...
        X