Skip to main content

Notifications

Community site session details

Community site session details

Session Id : HyNxkqFv8BK9OUwSq7cEJT
Power Apps - Building Power Apps
Unanswered

Avoid saving duplicate records to a SharePoint list

Like (0) ShareShare
ReportReport
Posted on 31 Jan 2024 09:17:44 by

Good day

 

I have an "Event booking app" and need to check 2 fields when submitting to the SharePoint list - i.e. the Date field and the Time field.  One should not be able to submit if those 2 fields have identical data in it.

janineb_0-1706692581142.png

Also, can you perhaps help me with the delegation warning on the gallery?  

Sort(Filter(EventBookingSlots,Date=DatePicker1.SelectedDate), StartTime.Value,SortOrder.Ascending)

 

Thank you

 

  • janineb Profile Picture
    on 31 Jan 2024 at 10:38:31
    Re: Avoid saving duplicate records to a SharePoint list

    Unfortunately I am still getting an error - the system does not seem to recognise "FilteredEvents"

     

    janineb_0-1706697482476.png

     

  • mmbr1606 Profile Picture
    12,121 Super User 2025 Season 1 on 31 Jan 2024 at 10:33:35
    Re: Avoid saving duplicate records to a SharePoint list

    please try the modified approach:

    If(
     CountRows(
     Filter(
     FilteredEvents,
     StartTime = StartTimedd.SelectedText,
     EndTime = EndTimedd.SelectedText
     )
     ) > 0,
     Notify("Event with the same Date, Start Time, and End Time already exists.", NotificationType.Error),
     Patch(
     EventBookingSlots,
     Defaults(EventBookingSlots),
     {
     Date: DatePicker1.SelectedDate,
     StartTime: StartTimedd.SelectedText,
     EndTime: EndTimedd.SelectedText,
     Title: DetailsTxt.Text,
     EventName: EventnameLbl.Text,
     Venue: VenueTxt.Text
     }
     )
    )
  • janineb Profile Picture
    on 31 Jan 2024 at 10:29:54
    Re: Avoid saving duplicate records to a SharePoint list

    On this part of your code, I am not too worried about the Delegation warning - but it complains about incompatible type for comparison.  It also says "Countrows" is not supported by this connector

     

     

    janineb_0-1706696897235.png

     

  • mmbr1606 Profile Picture
    12,121 Super User 2025 Season 1 on 31 Jan 2024 at 10:28:59
    Re: Avoid saving duplicate records to a SharePoint list

    you can try to just put FilteredEvents in your items Property of your gallery

     

    there only the items of the collection called FilteredEvents will show

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • janineb Profile Picture
    on 31 Jan 2024 at 10:25:50
    Re: Avoid saving duplicate records to a SharePoint list

    The gallery is called "galOverview".

     

  • mmbr1606 Profile Picture
    12,121 Super User 2025 Season 1 on 31 Jan 2024 at 10:04:13
    Re: Avoid saving duplicate records to a SharePoint list

    this is no error, its a delegation warning.

     

    you can set the delegation limit in the app settings to 2.000 entried (per default its 500).

    if you are below the 500 or 2000 entries this should work without problems.

     

    what is the gallery in your app called?

  • janineb Profile Picture
    on 31 Jan 2024 at 10:00:13
    Re: Avoid saving duplicate records to a SharePoint list

    Thank you for the guidance, however I am getting this error:

    janineb_1-1706694991073.png

    Also, for the gallery - I need to sort the time in descending order for that specific day so I cannot use

    Filter(EventBookingSlots, Date = DatePicker1.SelectedDate)

     

     

     

  • mmbr1606 Profile Picture
    12,121 Super User 2025 Season 1 on 31 Jan 2024 at 09:31:05
    Re: Avoid saving duplicate records to a SharePoint list

    please try this instead:

    If(
     Value(StartTimedd.SelectedText.Value) > Value(EndTimedd.SelectedText.Value),
     Notify("End Time cannot be less than Start Time", NotificationType.Error),
     If(
     CountRows(
     Filter(
     EventBookingSlots,
     Date = DatePicker1.SelectedDate,
     StartTime = StartTimedd.SelectedText,
     EndTime = EndTimedd.SelectedText
     )
     ) > 0,
     Notify("Event with the same Date, Start Time, and End Time already exists.", NotificationType.Error),
     Patch(
     EventBookingSlots,
     Defaults(EventBookingSlots),
     {
     Date: DatePicker1.SelectedDate,
     StartTime: StartTimedd.SelectedText,
     EndTime: EndTimedd.SelectedText,
     Title: DetailsTxt.Text,
     EventName: EventnameLbl.Text,
     Venue: VenueTxt.Text
     }
     )
     )
    )

     

    and this for ur other issue:

    Filter(EventBookingSlots, Date = DatePicker1.SelectedDate)

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • janineb Profile Picture
    on 31 Jan 2024 at 09:27:09
    Re: Avoid saving duplicate records to a SharePoint list

    OnSelect of the Submit button:

    If(Value(StartTimedd.SelectedText.Value)>Value(EndTimedd.SelectedText.Value),Notify("End Time cannot be less than Start Time",NotificationType.Error), Patch(EventBookingSlots, Defaults(EventBookingSlots),{Date: DatePicker1.SelectedDate, StartTime: StartTimedd.SelectedText, EndTime: EndTimedd.SelectedText, Title: DetailsTxt.Text, EventName: EventnameLbl.Text, Venue: VenueTxt.Text}))

     

    On the gallery:

    Sort(Filter(EventBookingSlots,Date=DatePicker1.SelectedDate), StartTime.Value,SortOrder.Ascending)

  • mmbr1606 Profile Picture
    12,121 Super User 2025 Season 1 on 31 Jan 2024 at 09:21:24
    Re: Avoid saving duplicate records to a SharePoint list

    hey @janineb 

     

    can you please copy /paste the code from the screenshot so we do not need to retype?

     

    thanks in advance

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,731 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,075 Most Valuable Professional

Leaderboard