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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / verifying if exist any...
Power Apps
Answered

verifying if exist any event before creating a new one

(0) ShareShare
ReportReport
Posted on by

hello everyone. I need to create an app that makes bookings for auditoriums and classrooms, but before creating an event or reservation, I need to verify that there is space, both physically and in time. I created a code, but it is not validating the existence of the previous event.

 

If(CountIf('test calendar';'Ubicación'=Dropdown1.SelectedText.Value;'Hora de inicio'=DateValue1.SelectedDate;'Hora de finalización'=DateValue2.SelectedDate)=0;If(SubmitForm(Form1);;ResetForm(Form1);Notify("Evento creado correctamente";NotificationType.Success;3000);Notify("Ha ocurrido un error. Por favor comunicarse con TI";NotificationType.Error;3000));Notify("Ya existe un evento en el "+Dropdown1.SelectedText.Value+" a esa misma hora en ese mismo día";NotificationType.Error;3000))

 

any ideas? thks

Categories:
I have the same question (0)
  • Verified answer
    Hassan_SZ_365 Profile Picture
    542 on at

    Hi  , 

    Here's a refined version of the code you provided:

     
    If(
    CountRows(
    Filter(
    'test calendar',
    'Ubicación' = Dropdown1.SelectedText.Value,
    'Hora de inicio' < DateValue2.SelectedDate + Time(Value(HourValue2.Text), Value(MinuteValue2.Text), 0),
    'Hora de finalización' > DateValue1.SelectedDate + Time(Value(HourValue1.Text), Value(MinuteValue1.Text), 0)
    )
    ) = 0,
    // No conflicting event, proceed with form submission
    If(
    SubmitForm(Form1),
    Notify("Evento creado correctamente", NotificationType.Success, 3000),
    Notify("Ha ocurrido un error. Por favor comunicarse con TI", NotificationType.Error, 3000)
    ),
    // Conflicting event found, notify the user
    Notify("Ya existe un evento en el " & Dropdown1.SelectedText.Value & " a esa misma hora en ese mismo día", NotificationType.Error, 3000)
    )

    Make sure to replace placeholder text with the actual names of your columns for location, start time, and end time in the 'test calendar' list and adjust the date and time manipulation based on how your date and time are structured in your app.

     

    Best Regards,

    Hassan Raza

    @jdanielhdezr

  • jdanielhdezr Profile Picture
    on at

    Thanks for your solution, it worked perfect in that scenario, but in time ranges it still doesn't respect the booking. For example, if there is a booking from 8 a.m. to 7 p.m., and a new one is added in the same place between 10 a.m. and 3 p.m., it does so as the code allows it, or between 7 a.m. and 11 a.m. How can that be solved?

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 408

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 319

Last 30 days Overall leaderboard