web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Prevent duplicate entries in a List

(0) ShareShare
ReportReport
Posted on by 59
 
I use a button to update my List, and it works.
 
Before updating, I want to check if the combination of "Place"+"Month"+"Year" exists in the List, and if it does, do not add an entry.
 
I've tried many things, but I always get error.
 
This is my code :
 
// This is one thing I tried for the duplicate check, but I get errors for the comparisons, "Incompatible types for comparison.".
Set(
    existingRecord,
    LookUp(
        'Fréquentation mensuelle',
        Lieu = Lieu.SelectedText &&
        Mois = MonthDropdown.SelectedText &&
        Année = Value(YearInput.Text)
    )
);
 
If(
    IsBlank(existingRecord),
    Patch(
        'Fréquentation mensuelle',
        Defaults('Fréquentation mensuelle'),
        {
            Lieu: Lieu.SelectedText,
            Mois: MonthDropdown.SelectedText,
            Année: Value(YearInput.Text),
            Visiteurs: Value(PeopleInput.Text)
        }
    );
 
    Reset(PeopleInput);
    Notify("Succès", NotificationType.Success),
    // If duplicate exists, show error notification
    Notify("Ce lieu pour ce mois et cette année existe déjà.", NotificationType.Error)
);
I have the same question (0)
  • Suggested answer
    trogne Profile Picture
    59 on at
    Prevent duplicate entries in a List
    This works! :
    ClearCollect(
        AllRecords,
        'Fréquentation mensuelle'
    );
     
    ClearCollect(
        FilteredRecords,
        ForAll(
            AllRecords,
            {
                LieuText: Lieu.Value,
                MoisText: Mois.Value,
                AnneeText: Text(Année)
            }
        )
    );
     
    Set(
        duplicateRecord,
        LookUp(
            FilteredRecords,
            LieuText = Lieu.Selected.Value &&
            MoisText = MonthDropdown.Selected.Value &&
            AnneeText = Text(Value(YearInput.Text))
        )
    );
     
    Set(duplicateFound, !IsBlank(duplicateRecord));
     
    If(
        duplicateFound,
        Notify("Ce lieu-mois-année existe déjà.", NotificationType.Error),
        Patch(
            'Fréquentation mensuelle',
            Defaults('Fréquentation mensuelle'),
            {
                Lieu: { Value: Lieu.Selected.Value },
                Mois: { Value: MonthDropdown.Selected.Value },
                Année: Value(YearInput.Text),
                Visiteurs: Value(PeopleInput.Text)
            }
        );
     
        Reset(PeopleInput);
        Notify("Succès", NotificationType.Success)
    );


     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 651 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 385 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 230 Super User 2025 Season 2

Last 30 days Overall leaderboard