
Is there a way to enforce the required fields so a record row will not be added unless all required fields are completed?
Is there a way to enforce the required fields so a record row will not be added unless all required fields are completed?
-
Alternatively you can use some logig steps (this is not the same but you 'll get warning), for example
---
let t := this;
if RequiredField = null then
let check := dialog("Attention", "This Field can not be empty bla bla bla", ["OK", "Delete"]);
if check = "Delete" then delete this end
end---
*If you press "Delete" will delete the record.
-
Hi Nick,
Ok, I understand. It's working now :-)
But if I'm correct, in theory you are not really saving it when pressing the button. It's more like a check. So there is still a way of adding records with empty RequiredFields.
So not really what I was hoping to do but it was a good learning on triggers :-)
Thx.
-
@Tom,
That is correct.. Ninox Partner Maarten Thiebou presented an interesting "hack"... It is a way to use html / css to "hide" the "X" in the upper left, and add a button to save/close.. where you can put the logic. That said.. users can still move off the table, or simply close the application and add invalid data. :(
-
@Sarah
Antonello code will only work for the main form. You need the following for the subsequent pop up forms:
html("<style> .popupeditor2-buttons-left .button { display: none; } </style> ")
I have observed no noticable impacts on "speed" of the database.
Note.. The user could still navigate off the record, close the table or database (etc) and the data would still be empty.
-
Another possible workaround would be to create a separate table that matches the table you are adding records to. In Nick's example there is a "Save" button. In this workaround you would add an "Add Record" button and use
popupRecord()
to call the separate table form. You can then do all the input validation you want and a new record would only be added to the main table once "Save" is clicked on the subform.Of course, there isn't anything preventing the user from clicking the "+" to add a record.
-
@Mconneen, I remember reading about that approach in Alan Simpson's book "Understanding dBASE IV" almost 30 years ago, LOL. If I recall correctly, it was characterized as... "There is a school of thought that you shouldn't add records directly to the database". It's not one that I implemented at the time though.
-
While all these approaches are great, it feels like we're trying to "stand on our heads" and doing cartwheels for something that should be fairly straightforward and as Sean elluded to that writing to this database should not be done directly. It's seems almost worth the time, instead of hacking, to just use the Ninox API in order to access the DB and create one's own interface to limit the user's ability to save. Just my two cents...
-
@Nick, one trick is this...
html("
<style>
.hud-menu-button.menu-icon.menu-icon-trash{display: none;}
.hud-menu-button.menu-icon.menu-icon-duplicate{display: none;}
.hud-menu-button.menu-icon.menu-icon-add{display: none;}
</style>
")
The problem is it only works when a Form view is present and there's nothing you can do about the menu options in the apps. I posted a database named NoEmptyFieldsOrRecords, a bit of a misnomer, on the Webinar page that demonstrates the workaround. Feel free to add and edit records. Obviously, the Contacts Add and Contacts Edit tables would be hidden as well as the formula field.