Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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

  • jdanielhdezr Profile Picture
    on at
    Re: verifying if exist any event before creating a new one

    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?

  • Verified answer
    Hassan_SZ_365 Profile Picture
    542 on at
    Re: verifying if exist any event before creating a new one

    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

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1