Holiday day alert
Hi, I am looking for guidance on a syntax/formula issue.
I want to alert a user if they select a predetermined holiday date.
I have a logistics booking table with two dates: one for collection and one for delivery.
I already have a day of the week displaying based on the date selected.
I want to include a dialog pop up to confirm the date if the user selects a holiday date.
To that end I have created a linked table for holiday dates.
I‘m fine with creating the dialog but can’t get the right syntax to allow the date on the booking table to be compared with all the records in the holiday table.
I have searched the forum but cannot find the right answer.
Any advice/suggestions are much appreciated
Many thanks
6 replies
-
Please post the code you are using.
-
Please post the code you are using.
-
Hi Fred, This will not be the best code you have ever seen but I am still very much a begineer ;-)
if 'Ship Date' like Dates.Date then
let result := dialog("", "This is a national holiday. Do you wish to proceed?", ["Yes", "No"]);
if result = "No" then 'Ship Date' := false end
endDates is the holidays table.
The Dialog works as designed but it is triggered on any date entered.
Many thnaks for any help
-
Hi Rob -
I don't get any dialog to show up if I put in the Trigger after update. I can get alerts to show up but no dialogs. I'm using the MacOS app.
If I put it in a button then dialogs work. So you must have a special version of Ninox. :)
But back to your code.
It looks like in your booking table you have a reference field to the Dates table (your reference to Dates.Date in your if statement). What your if statement does is just compare the 'Ship Date' of the current record to the Dates.Date data linked to the current record. I'm guessing the Dates field is empty on the record.
What you need to do is add these lines to the beginning:
let curRec := this; <--collects the data of the current record
let xDate := cnt(select Dates where Date = curRec.'Ship Date'); <--checks the Dates table for any records where the Date field matches the Ship Date field in the bookings table then counts the number of records returned
if xDate > 0 then <--if the count is larger than 0 that means there is a record where the dates match so we want to warn peoplelet result := dialog("", "This is a national holiday. Do you wish to proceed?", ["Yes", "No"]);
if result = "No" then 'Ship Date' := false end
endHope that helps.
-
Hi Fred, Firstly, thank you for taking the time to look at this for me. I will be giving that a go first thing in the morning :-)
You are quite correct that the field is empty ;-)
That is odd, I copied the dialog functionality from a formula field that I have to prevent text being accidentally overwritten. I’m using the current Mac version.
Thanks again for the assistance, it is much appreciated. -
Hi Fred, That solution was perfect. Thank you so much for helping
Thank you also for the description of what each code line was doing. This helps greatly when I try in the future to adapt it for other uses.
Content aside
- 3 yrs agoLast active
- 6Replies
- 421Views