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 : xNeCTuR+ZhF8ABXmc7RpZ0
Power Apps - Building Power Apps
Answered

verifying if exist any event before creating a new one

Like (0) ShareShare
ReportReport
Posted on 22 Nov 2023 17:41:58 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

I have the same question (0)
  • jdanielhdezr Profile Picture
    on 22 Nov 2023 at 20:16:57
    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 22 Nov 2023 at 18:09:11
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 982 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 396 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 356

Last 30 days Overall leaderboard