Button. On click - No empty fields and if there’s a dup confirm before adding record via dialog
I’m trying to make sure all the important fields are filled out when adding new record and if such record already exists to ask for confirmation before proceeding. I’m very beginner at this so I can’t figure out how to get it to work properly. Currently I have this code :
let LD := 'Load ID';
let mm := 'Yr/Make/Model';
let r := 'Rate ($)';
let pu := 'Pick-Up Date';
let pul := 'Pick-Up Location';
if LD = null then
alert("Enter Load ID")
else
if mm = null then
alert("Enter Year/Make/Model")
else
if r = null then
alert("Enter Rate Amount")
else
if pu = null then
alert("Enter Pick Up Date")
else
if pul = null then
alert("Enter Pick Up Location")
else
if Broker = null then
alert("Add Broker")
else
if Drivers = null then
alert("Add Driver")
else
let findDup := cnt((select Report)['Load ID' = LD and 'Yr/Make/Model' = mm and 'Rate ($)' = r and 'Pick-Up Date' like pu and
'Pick-Up Location' like pul]);
let t := "Add New Load";
let m := "Similar record already EXISTS. Would you like to proceed and create New record?";
let ans := ["Yes", "No, open existing record", "No, Delete this"];
if findDup = 1 then
closeRecord()
else
if findDup > 1 then
if dialog(t, m, ans) = "Yes" then
closeRecord()
else
if dialog(t, m, ans) = "No, open existing record" then
openRecord(record(Report,first(select Report
where 'Load ID' = LD and 'Yr/Make/Model' = mm and 'Rate ($)' = r and 'Pick-Up Date' = pu and
'Pick-Up Location' = pul)))
else
if dialog(t, m, ans) = "No, Delete this" then
delete this
end
end
end
end
end
end
end
end
end
end
end
end
I know it’s long and probably there’s a better way to script all that, but It works up to one detail.
if dialog(t, mm, and) = “No, open existing record”
I want the current record to be voided and existing to open. But can’t figure out how to get this record to be voided or deleted.
2 replies
-
Welcome to Ninox.
You have encountered the first big design point when developing a DB. How to control data entry.
May I introduce you the concept of “Dashboards”. You can view this video for a good introduction.
The idea here is that you create a form that your users use to enter in data and then you can do quality control before any records get created. We know we can’t trust users to do the right thing,
, so we have to control all aspects of the user interaction to make sure the data is clean and accurate.
It is only a small redesign of your DB, but will be very powerful. I have a DB that only I use, but I use dashboards all the time. I rarely create new records in my raw data tables manually.
Content aside
- 1 yr agoLast active
- 2Replies
- 89Views
-
2
Following