Hi,
I am working on a Seat Availability App, where in Submit buttion, I have to put some condtions:
1. If any required field is empty, throw a message: Please fill the required fields
2. If Selected date is a past day, throw a message: Selected date can not be before Today's date
3. If a person have booked his/her seat for particular day and location already, then: Oops! looks like you have already booked for this date and location
4. If user chooses Canada and 25 people have already booked for a particular day, then: Oops! No availability for this date, kindly book for some other date or Location
5. If user chooses USA and 100 people have already booked for a particular day, then: Oops! No availability for this date, kindly book for some other date or Location
If everything goes well, then Submit the form and popup should appear: Saved successfully.
** Here first 3 conditions are working fine, however 4,5 are acting little weird, sometime it throws the "No availability" message even if seats are available for a particular location.
--------------------------------
If(
IsBlank(Location.SelectedItems.Value) || IsBlank(Employee.SelectedItems.DisplayName) || IsEmpty(Employee.SelectedItems.DisplayName) || IsEmpty(Location.SelectedItems.Value),
Notify("Please fill the required fields"),
Date.SelectedDate<Today(),
Notify("Selected date can not be before Today's date"),
If(
CountRows(Filter('Seat Availability',
'Employee Name'.DisplayName= Employee.Selected.DisplayName && Date = Date.SelectedDate && 'Location Name'.Value = Location.Selected.Value))=1,
Notify("Oops! looks like you have already booked for this date and location.."),
CountIf('Seat Availability',
Location.Selected.Value = "Canada" && Date = Date.SelectedDate)<=24
,SubmitForm(Form1); NewForm(Form1); UpdateContext({Popup: true}),Notify("Oops! No availability for this date, kindly book for some other date or Location")
, CountIf('Seat Availability',
Loaction.Selected.Value = "USA" && Date = Date.SelectedDate)<=99
, SubmitForm(Form1); NewForm(Form1); UpdateContext({Popup: true}),Notify("Oops! No availability for this date, kindly book for some other date or Location")
))
----------------------------------------
Please help me to rectify the code, its getting very very urgent.
Solved! Go to Solution.
Hi @rsinha ,
Please try below instead:
If(
IsBlank(Location.SelectedItems.Value) || IsBlank(Employee.SelectedItems.DisplayName) || IsEmpty(Employee.SelectedItems.DisplayName) || IsEmpty(Location.SelectedItems.Value),
Notify("Please fill the required fields"),
Date.SelectedDate<Today(),
Notify("Selected date can not be before Today's date"),
CountRows(Filter('Seat Availability',
'Employee Name'.DisplayName= Employee.Selected.DisplayName && Date = Date.SelectedDate && 'Location Name'.Value = Location.Selected.Value))=1,
Notify("Oops! looks like you have already booked for this date and location.."),
If(
(Location.Selected.Value = "Canada" && CountIf('Seat Availability','Location Name'.Value = "Canada" && Date = Date.SelectedDate)<=24)) || (Location.Selected.Value = "USA" && CountIf('Seat Availability','Location Name'.Value = "USA" && Date = Date.SelectedDate)<=99),
SubmitForm(Form1); NewForm(Form1); UpdateContext({Popup: true}),
Notify("Oops! No availability for this date, kindly book for some other date or Location")
)
)
Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.
Hi @rsinha ,
Please try below instead:
If(
IsBlank(Location.SelectedItems.Value) || IsBlank(Employee.SelectedItems.DisplayName) || IsEmpty(Employee.SelectedItems.DisplayName) || IsEmpty(Location.SelectedItems.Value),
Notify("Please fill the required fields"),
Date.SelectedDate<Today(),
Notify("Selected date can not be before Today's date"),
CountRows(Filter('Seat Availability',
'Employee Name'.DisplayName= Employee.Selected.DisplayName && Date = Date.SelectedDate && 'Location Name'.Value = Location.Selected.Value))=1,
Notify("Oops! looks like you have already booked for this date and location.."),
If(
(Location.Selected.Value = "Canada" && CountIf('Seat Availability','Location Name'.Value = "Canada" && Date = Date.SelectedDate)<=24)) || (Location.Selected.Value = "USA" && CountIf('Seat Availability','Location Name'.Value = "USA" && Date = Date.SelectedDate)<=99),
SubmitForm(Form1); NewForm(Form1); UpdateContext({Popup: true}),
Notify("Oops! No availability for this date, kindly book for some other date or Location")
)
)
Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.
User | Count |
---|---|
256 | |
111 | |
95 | |
48 | |
40 |